Condition Statement MCQ 4 : Multiple conditions inside if statement
If - Else MCQ : Multiple Conditions Separated by Comma Operator
#include<stdio.h> void main() { int a=1,b=2; if(printf("%d",printf("123")),0) { printf("Connected"); } else { printf("Disconnected"); } }
Options :
- 123Connected
- 1233Connected
- 123Disconnected
- 1233Disconnected
Why ?
printf("%d",printf("123"))
- This is Example of nested Printf
- Inner printf will return number of Character Printed to Outer Printf so 1233 will be surly Printed.
- If statement will execute else part because if(1233,0). will results in if (0) - ” In Short Comma Operator Returns Rightmost Operand”so “Disconnected” will be printed