C Loops Quiz Form
Test your knowledge of C programming loops with this 10-question quiz. Please answer all questions to the best of your ability.
Which of the following is the correct syntax for a 'for' loop in C?
*
for (int i = 0; i < 10; i++)
for i = 1 to 10
foreach (i in 0..10)
loop (i = 0; i < 10; i++)
What is the output of the following code? int i = 0; while (i < 3) { printf("%d ", i); i++; }
*
0 1 2
1 2 3
0 1 2 3
Infinite loop
Select all valid loop types in C.
*
for
while
do-while
repeat-until
What will the following code print? for (int i = 0; i < 5; i++) { if (i == 2) break; printf("%d ", i); }
*
0 1
0 1 2
0 1 2 3 4
1 2
How many times will the following loop execute? int i = 1; do { printf("Hello"); i++; } while (i < 4);
*
3
4
1
0
Which statement is used to skip the current iteration in a loop?
*
continue
break
skip
exit
Write a single line of C code that prints numbers from 1 to 10 using a for loop.
*
Which of the following statements about 'do-while' loops is true?
*
A 'do-while' loop always executes at least once.
A 'do-while' loop may never execute.
A 'do-while' loop and a 'while' loop are identical.
'do-while' loops cannot contain 'break' statements.
What is the value of 'i' after the following loop? int i = 0; for (; i < 4; i++) {}
*
4
3
0
1
Rate your confidence in using loops in C (1 = Not confident, 5 = Very confident).
*
1
2
3
4
5
Submit Quiz
Should be Empty: