C Code Output Analysis Technique

What is the output of the following C code? int main () { int x = 5; printf("%dn", x++); return 0;

Answer: 5
Explanation
  • The printf("%dn", x++); prints the value of x before incrementing it.
  • Since x++ is a post-increment operator, the value of x (5) is printed first, and then x becomes 6 after the statement.
  • This question appeared in Past Papers (1 times)
    This question appeared in Subjects (1 times)

    Install this app on your device for quick access right from your home screen.