` Question 13 int main() { if((1,0)) printf("True"); else printf("false"); return 0; }...
Palo Alto Networks technical mcq question, verified with a worked answer. Free to practise - no sign-up.
Question 13
int main()
{
if((1,0))
printf("True");
else
printf("false");
return 0;
}
Select any one of the following options
Show answer & explanation
Answer: B. B) FALSE
In C, the comma operator evaluates (1, 0) from left to right and returns the rightmost operand, 0. Since 0 is falsy, the else branch executes.
Step-by-step Derivation:
Step 1: The condition is (1, 0) enclosed in parentheses.
Step 2: The comma operator evaluates 1, discards it, and evaluates 0 as the result.
Step 3: if(0) evaluates to false in C.
Step 4: The else branch is taken, printing 'false' (FALSE).