LearnFrenzy
Sign in Take a free test

C Loops · Loops MCQ · Question 9

Iterations of two nested n-loops in C Answer, explanation & discussion

  • MCQ
  • Easy
  • 0 comments
  • Answer explained
  • Moderated community
Question 9 Back to Exercise

Both loops run from 0 to n − 1. How many times does the inner body execute?

  • A n
  • B 2n
  • C n × n Correct
  • D n + n²
Correct Answer: Option C

The inner loop runs n times for each of the n outer passes: n × n = n² – O(n²) time. Doubling n makes such code about four times slower.

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