LearnFrenzy
Sign in Take a free test

Operators and Expressions · Operators MCQ · Question 5

What does i = i++ do in C? Answer, explanation & discussion

  • MCQ
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
Question 5 Back to Exercise

What is the value of i after int i = 5; i = i++;?

  • A 5
  • B 6
  • C Undefined behaviour – i is modified twice without a sequence point Correct
  • D 7
Correct Answer: Option C

The assignment and the increment both modify i, and C does not order them. Some compilers give 5, others 6, and optimisers may do anything else. Clang warns "multiple unsequenced modifications to i".

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links