Condition Statement MCQ 1 : Non Zero number inside if
C MCQ : if statement > Non Zero number inside if statement
#include<stdio.h> void main() { int num=10; if(num) printf("If Executed"); else printf("Else Executed"); }
Options :
- If Executed
- Else Executed
- Compile Error : If Statement must have Condition.
- Run-Time Error
[toggle title="Output"]If Executed[/toggle]
Why & How ?
Non Zero Number is TRUE
- Any number except Zero in If is considered as TRUE
- Value of Variable “num = 10″ which is Considered as TRUE
- So IF block gets executed