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/x++)); 
    return 0; 
} 

(A) 590
(B) 1799
(C) 929
(D) Error


Answer: (C)

Explanation: (x+x*x-x/x++) is evaluated as:
=> 30 + 30 * 30 – 30 / 30 = 30 + 900 – 1 = 929
=> x++ is evaluated then as its postfix.

Quiz of this Question


Share your thoughts in the comments