+ 1
Here why am I getting my output as 0 only?!?
#include <stdio.h> int main() { int x=1; if(x) x=0; if(x) x=2; printf("%d",x); return 0; }
3 ответов
0
if (1) cout << "ok!";
if (0) cout << "nope... ";
edit: brains' answer is better. He actually explains it and I just gave an example. You should mark his answer as best ^^
+ 2
thanks,I get it now😊
0
int x=1 //x is true
if(x)evaluates to true
x=0//x becomes 0
if(x)evaluates to false since x is 0
x=2 //this block of code is not run
then x is still is 0