c++ help
Name:
Anonymous
2007-10-26 18:20
ok can you solve this?
find the value of val
bool val;
i = 0, j = -1, k = 1
val = (j*k && (!i||i-j-k)) where
Name:
Anonymous
2007-10-26 18:22
0?
Name:
Anonymous
2007-10-26 18:24
Name:
Anonymous
2007-10-26 18:29
1. Substitute
2. Apply logic
3. ?????
4. Homework
Name:
Anonymous
2007-10-26 18:32
ok so i get (-1 and 0 or 0)
Name:
Anonymous
2007-10-26 18:33
>>2
Oh shit, didn't notice the !
Anyways,
val = ( (-1) * (1) && ( !(0) || (0)-(-1)-(1) ) )
val = ( -1 && ( 1 || 0 ) )
val = ( -1 && 1 )
val = -1
val = 0?
Does -1 just change to 0? Not much experience with logic in C++.
Name:
Anonymous
2007-10-26 18:36
wait, how does 1 or 0 change to 1?
Name:
Anonymous
2007-10-26 18:37
you guys are fucking hopeless
undefined type for variable i, j, k
COMPILER ERROR, NEVER ASSUME ANYTHING
Name:
Anonymous
2007-10-26 18:39
>>7
Wut? Where the fuck did you learn logic from?
Also,
>>2,6,8 samefag
Name:
Anonymous
2007-10-26 18:40
>>8
Pseudocode?
>>9
Meant
>>2,6,9
Name:
Anonymous
2007-10-26 18:40
umm doesnt || mean or?
Name:
Anonymous
2007-10-26 18:44
>>11
Yes. Srsly, look up a quick guide on logic or something.
Name:
Anonymous
2007-10-26 19:55
-1 evaluates to true, so val is true.
Name:
Anonymous
2007-10-26 20:19
>>12
Retarded C syntax has nothing to do with logic.
Name:
Anonymous
2007-10-26 20:27
>>14
|| is used for logical OR in most modern languages. If you haven't encountered it, you don't belong on /prog/.
Name:
Anonymous
2007-10-26 21:40
>>13
Huh. Odd, but interesting. I'll keep it in mind any time I use logic in C++.
Name:
Anonymous
2007-10-26 22:26
>>15
the whole problem is not about logic, but about operator precedence.
Name:
Anonymous
2007-10-27 6:50
>>17
Operator precedence does not matter here, every order will give the same answer. Also
>>8 is right.
Name:
Anonymous
2007-10-27 6:59
op here, ok assume it is declared and everything, what does this statement come out to be
Name:
Anonymous
2007-10-27 7:05
Name:
Anonymous
2007-10-27 7:21
YOU ARE ALL FUCKING CLUELESS.
Name:
Anonymous
2007-10-27 7:33
>>19
Your question has already been answered. It's true.
If you don't believe it:
>>> ((-1) and (not 0 or 0))
True
Name:
Anonymous
2007-10-27 9:19
Name:
Anonymous
2007-10-27 9:47
IDLE is the gayest IDE ever.
Name:
Anonymous
2007-10-27 13:19
>>24
You can use Python without using IDLE, faggot.
Name:
Anonymous
2009-03-06 7:41
Haven't used enough caramel.
Name:
Anonymous
2011-02-03 6:00