+ 1

What does this mean?(Related to if statements)

if(!(a>b)){ //some code for output } What does that exclamatory mark mean? Edit0:I got the meaning but I have one question can't we just write b>a instead of this. Edit1:Thanks to Sean And Abdul for the answer.

5th Apr 2017, 4:52 PM
Maulik Bharatsinh Parmar
Maulik Bharatsinh Parmar - avatar
7 Answers
+ 11
Same as if (a<=b)
5th Apr 2017, 5:58 PM
Tashi N
Tashi N - avatar
+ 1
No, (b > a) isn't the same thing, but you could write (b >= a).
5th Apr 2017, 4:58 PM
DaemonThread
DaemonThread - avatar
0
It means "not". Basically, it's checking if a is not greater than b.
5th Apr 2017, 4:54 PM
DaemonThread
DaemonThread - avatar
0
Can't we just write b>a instead of this?
5th Apr 2017, 4:55 PM
Maulik Bharatsinh Parmar
Maulik Bharatsinh Parmar - avatar
0
Thanks
5th Apr 2017, 5:01 PM
Maulik Bharatsinh Parmar
Maulik Bharatsinh Parmar - avatar
0
@Abdul It's checking if a is not greater than b. For the if statement to work, b has to be greater than or equal to a. If a is equal to b, then it still fulfills the condition.
5th Apr 2017, 5:03 PM
DaemonThread
DaemonThread - avatar
0
@Abdul ...Hang on, let me clarify. Let's say a = 5 and b = 7. Thus, we can replace them like this: if (!(5 > 7)) = true Now let's say a = 5 and b = 5. if (!(5 > 5)) = true So the if condition still works if a and b are equal, so it's the same as: if (b >= a)
5th Apr 2017, 5:12 PM
DaemonThread
DaemonThread - avatar