+ 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.
7 Answers
+ 11
Same as
if (a<=b)
+ 1
No, (b > a) isn't the same thing, but you could write (b >= a).
0
It means "not". Basically, it's checking if a is not greater than b.
0
Can't we just write b>a instead of this?
0
Thanks
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.
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)