Find the output of the following program.
#include<stdio.h>
void main()
{
int y=10;
if(y++>9 && y++!=10 && y++>11)
printf("%d", y);
else
printf("%d", y);
}
#include<stdio.h>
void main()
{
int y=10;
if(y++>9 && y++!=10 && y++>11)
printf("%d", y);
else
printf("%d", y);
}
A. 11
B. 12
C. 13
D. 14
E. Compilation error
Answer: Option C
Solution(By Examveda Team)
All the three condition in if is true.if(y++>9 && y++!=10 && y++>11) such as
1st condition : 10++ > 9 is true and value of y is increase by 1 i.e y =11
2nd condition : 11++ != 10 is also ture and value of y is increase by 1 i.e y =12
3rd condition : 12++ > 11 is also ture and value of y is increase by 1 i.e y =13
Therefore if is excuted and print the value of y = 13
Join The Discussion
Comments ( 10 )
Related Questions on Operators and Expressions
What does the ++ operator do in C when applied to a variable?
A. Decrements by 1
B. Adds 1
C. Doubles the value
D. Leaves it unchanged
why they did not follow RIGHT TO LEFT property as , it is a unary opeartor???
Solution has been update please review you doubt.
why the answer is not 12
it is right answer i execute this programm
it is right answer i execute this programm
Sorry answer should be 12
Answer should be 11
i think 2nd statement is false so, no need to execute 3rd one.
ans should be 12.
In 'if' statement value will increases.
In IF statement the value of increases or not as it is conditional statement.