Warning: implode(): Invalid arguments passed in /www/wwwroot/jobquiz.info/mdiscuss.php on line 336 What will be the output of the program? #include<stdio.h> int main() { int x = 10, y = 20; if(!(!x) && x) printf("x = %d\n", x); else printf("y = %d\n", y); return 0; } ?->(Show Answer!)
1. What will be the output of the program? #include<stdio.h> int main() { int x = 10, y = 20; if(!(!x) && x) printf("x = %d\n", x); else printf("y = %d\n", y); return 0; }
Ask Your Doubts Here
Comments
By: guest on 01 Jun 2017 06.01 pm
The logical not operator takes expression and evaluates to true if the expression is false and evaluates to false if the expression is true. In other words it reverses the value of the expression. Step 1: if(!(!x) && x)
Step 2: if(!(!10) && 10)
Step 3: if(!(0) && 10)
Step 3: if(1 && 10)
Step 4: if(TRUE) here the if condition is satisfied. Hence it prints x = 10.
Step 2: if(!(!10) && 10)
Step 3: if(!(0) && 10)
Step 3: if(1 && 10)
Step 4: if(TRUE) here the if condition is satisfied. Hence it prints x = 10.