ExamVeda
Login
Home
Operators and Expressions
?

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);
}

Answer & Solution
Correct Answer: Option C
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
Examveda
Question posted by Examveda
Community

Join the Discussion

10 Comments
Sandeep Kunisetti
Sandeep Kunisetti 5 years ago
why they did not follow RIGHT TO LEFT property as , it is a unary opeartor???
Examveda
Examveda 9 years ago
Solution has been update please review you doubt.
Shashi Raj
Shashi Raj 9 years ago
why the answer is not 12
Miyank Kumar
Miyank Kumar 10 years ago
it is right answer i execute this programm
Miyank Kumar
Miyank Kumar 10 years ago
it is right answer i execute this programm
D&#38;D
D&#38;D 10 years ago
Sorry answer should be 12
D&#38;D
D&#38;D 10 years ago
Answer should be 11
Amar Raikwade
Amar Raikwade 10 years ago
i think 2nd statement is false so, no need to execute 3rd one.
ans should be 12.
Examveda
Examveda 10 years ago
In 'if' statement value will increases.
Diganta Patra
Diganta Patra 10 years ago
In IF statement the value of increases or not as it is conditional statement.