15,904,653 members
See more:
What does if(!a>="some number") mean?
is it same as if a is not greater than or equal to some number ??????
Like what will be the outcome of following?

C#
```#include<iostream>
using namespace std;
int main()
{
int a=500,
b=100,
c;
if(!a>=600)
b=300;
c=200;
cout<<b<<c;
return 0;
}```

What I have tried:

I tried understanding it as follow

if a is not greater than or equal to some number
so according to me it satisfies the following that a is not greater than or equal to 600 as it is initialised to 500, So b should change its value from 100 to 300.
plz tell where i am going wrong?
Posted
Updated 6-Dec-16 21:20pm
v3
CHill60 6-Dec-16 13:15pm
Is 'a' a numeric?
Member 12890185 6-Dec-16 13:18pm
yes
the actual question is
#include<iostream>
using namespace std;
int main()
{
int a=500,
b=100,
c;
if(!a>=600)
b=300;
c=200;
cout<<b<<c;
return 0;
}
Patrice T 6-Dec-16 13:24pm
Use Improve question to update your question.
So that everyone can pay attention to this information.
Member 12890185 6-Dec-16 13:26pm
@ppolymorphe
I have updated it now..
[no name] 6-Dec-16 13:30pm
"what will be the outcome of following?", run it and find out for yourself. Why are you making things so complicated? if (a < 600)

## Solution 2

It is all about operator precedence
C++ Operator Precedence - cppreference.com[^]
! have higher precedence than >=
It means that
C++
`if(!a>=600)`

is
C++
`if((!a)>=600)`

and in C 0 means false and any values not zero is true
so for a=500, !a is 0 and you have
C++
`if(0>=600)`

v2
CPallini 6-Dec-16 15:51pm
5.
Patrice T 6-Dec-16 15:53pm
Thank you.
CHill60 6-Dec-16 19:08pm
5'd. I'd originally posted a C# response and realised I was being unobservant. Called myself a few names and deleted my solution (hence yours is "2")
Patrice T 6-Dec-16 19:13pm
Thank you very much.