LearnFrenzy
Sign in Take a free test

C Loops · Loops MCQ · Question 7

for (unsigned i = 10; i >= 0; i--) – how many passes? Answer, explanation & discussion

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

How many times does for (unsigned i = 10; i >= 0; i--) run?

  • A 10
  • B 11
  • C It never stops: an unsigned i is always >= 0 Correct
  • D It does not run
Correct Answer: Option C

After 0, decrementing an unsigned value wraps to UINT_MAX, so i >= 0 is always true. Compilers warn "comparison is always true". Count down with for (unsigned i = 11; i-- > 0; ) or use a signed counter.

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