Last Updated : 14 Feb, 2019

What will be the output of the following program?

#include <stdio.h> 
int main(void) 
{ 
    int x = 30; 
    
    printf(\"%d\", ++x, x++, ++x, ++x); 
    
    return 0; 
} 

(A) 30
(B) 31
(C) 32
(D) 33
(E) 34


Answer: (E)

Explanation: ++x, x++, ++x, ++x is evaluated as
++x => x = 31
x++ => x = 32
++x => x = 33
++x => x = 34
In the last x is sent to be printed with value 34.


Quiz of this Question


Share your thoughts in the comments