C Programming :: Basic Concepts - Discussion
Home > C Programming > Basic Concepts > MCQs Questions Discussion
10 / 90
What will be the output of the below C program.
#include<stdio.h>
int main(){
int a= 0;
int b = 20;
char x =1;
char y =10;
if(a,b,x,y)
printf("hello");
return 0;
}
#include<stdio.h>
int main(){
int a= 0;
int b = 20;
char x =1;
char y =10;
if(a,b,x,y)
printf("hello");
return 0;
}
Ahello
BCompilation Error
Cno output No Error
DNone of these
Answer: Option (Login/Signup)
Show Explanation
Asked In ::
STEP-BY-STEP
Comma(,) has associativity from left to right.
In line 7, i.e, if(a,b,x,y), only the last variable will be checked as a test condition, rest all other will be ignored.
Now, the if part becomes something like if(y), or if(10), which is True, as 10 is not equal to zero. Hence, the if part gets executed, and we get output as hello.
Read Full Answer
Report Error
Please Login First Click Here