-
Which of the following is the correct output for the program given below?
#include <studio.h>
int main()
{
int a = 50, b = 60;
if(!(!a) &&a)
printf("a = %d\n",a)'
else
printf("b = %d\n",b);
return 0;
}
-
- b = 60
- a = 0
- a = 50
- a = 1
Correct Option: C
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(!(!a) && a)
Step 2: if(!(!50) && 50)
Step 3: if(!(0) && 50)
Step 3: if(1 && 50)
Step 4: if(TRUE) here the if condition is satisfied. Hence it prints a = 50.