Examveda
Examveda

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

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

This Question Belongs to C Program >> Operators And Expressions

Join The Discussion

Comments ( 10 )

  1. Sandeep Kunisetti
    Sandeep Kunisetti :
    3 years ago

    why they did not follow RIGHT TO LEFT property as , it is a unary opeartor???

  2. Examveda
    Examveda :
    7 years ago

    Solution has been update please review you doubt.

  3. Shashi Raj
    Shashi Raj :
    7 years ago

    why the answer is not 12

  4. Miyank Kumar
    Miyank Kumar :
    7 years ago

    it is right answer i execute this programm

  5. Miyank Kumar
    Miyank Kumar :
    7 years ago

    it is right answer i execute this programm

  6. D&D
    D&D :
    7 years ago

    Sorry answer should be 12

  7. D&D
    D&D :
    7 years ago

    Answer should be 11

  8. Amar Raikwade
    Amar Raikwade :
    8 years ago

    i think 2nd statement is false so, no need to execute 3rd one.
    ans should be 12.

  9. Examveda
    Examveda :
    8 years ago

    In 'if' statement value will increases.

  10. Diganta Patra
    Diganta Patra :
    8 years ago

    In IF statement the value of increases or not as it is conditional statement.

Related Questions on Operators and Expressions