1) Why isn't this post in the C/C++ forum?
2) You forgot braces after the if statement. This means only the next statement after if() is executed. The value of b is 0 because a is not grater than or equal to 400, so the statement b=300 after if() is not executed. Corrected version:
-
int main()
-
{
-
int a=300,b,c;
-
if(a>=400)
-
{
-
b=300;
-
c=200;
-
}
-
printf("\n%d %d",b,c);
-
}
-
Note some other things. If a is smaller than 400, then b and c will be uninitialized. This does not mean that they will always be zero, they appear to be because you have implicitly cast them to double in your print statement when they are in fact int. The correct print statement is printf("%i %i\n",b,c); then you will see you get a large negative number corresponding the minimum value of an integer on your system (because they are uninitialized).