LearnFrenzy
Sign in Take a free test

C Loops · Exercise 1 of 4

C Loops Loops MCQ

  • 12 questions
  • Page 1 of 2
  • Answers explained
0Attempted
0Correct
0Wrong
Directions

Twelve multiple-choice questions on for, while and do-while, break and continue, loop scope, unsigned and floating-point counters, and nested-loop complexity. Pick an option to check your answer instantly.

Question 1 Easy

Which loop always executes its body at least once?

A for
B while
C do-while
D None of them
Question page & discussion
Question 2 Easy

What does for (;;) { … } do?

A It does not compile
B It runs once
C It is an infinite loop – a missing condition counts as true
D It never runs
Question page & discussion
Question 3 Medium

In a for loop, where does continue transfer control?

A To the start of the body
B To the update expression, then the condition
C Out of the loop
D To the initialisation
Question page & discussion
Question 4 Easy

break is executed inside the inner loop of two nested loops. What happens?

A Both loops end
B Only the inner loop ends; the outer loop continues
C The program ends
D Only the outer loop ends
Question page & discussion
Question 5 Easy

How many times does the body of for (int i = 0; i < 10; i += 3) run?

A 3
B 4
C 10
D 9
Question page & discussion
Question 6 Easy

After for (int i = 0; i < 5; i++) { … }, can you use i on the next line?

A Yes, it holds 5
B Yes, it holds 4
C No – since C99 its scope is the loop only
D Only if it is static
Question page & discussion
Question 7 Medium

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
D It does not run
Question page & discussion
Question 8 Medium

What is the risk in for (float x = 0.0f; x != 1.0f; x += 0.1f)?

A None
B 0.1 is not exact in binary, so x may never equal 1.0 and the loop may never stop
C float cannot be used in a for loop
D It runs exactly 10 times on every machine
Question page & discussion
Question 9 Easy

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

A n
B 2n
C n × n
D n + n²
Question page & discussion
Question 10 Easy

What is the difference between while (1) and for (;;)?

A while (1) is faster
B for (;;) is faster
C None – both are infinite loops and compile to the same code
D for (;;) runs once
Question page & discussion

Ready to test your Programming?

Timed online tests with instant scores and explanations.

Search LearnFrenzy

Esc

Quick links