This quiz contains questions from loops and conditional statements in C. Which is perfect to test your understanding of the topic.
Question 1
Which statement is used to skip the current iteration in a loop?
break
exit
Continue
goto
Question 2
What is the default value of a loop control variable in C?
0
1
Undefined
Compiler Dependent
Question 3
Which loop executes the body at least once, regardless of the condition?
for
while
do-while
if-else
Question 6
Which of the following is TRUE about switch statements in C?
switch can evaluate expressions
case labels must be strings
default is mandatory
You cannot use break in switch
Question 7
Which part(s) of a for loop are optional in C?
Initialization
Condition
Increment
All of the above
Question 8
Can you place a function call inside the initialization part of the for loop?
for (printf("Init\n"); i < 3; i++) { printf("Body\n");
No, only variable declarations are allowed
Only arithmetic expressions are allowed
Causes a runtime error
Yes, function calls are valid
Question 9
#include <stdio.h> int main() { int i = 1024; for (; i; i >>= 1) printf("GeeksQuiz"); return 0; }
How many times will GeeksQuiz be printed in the above program?
10
11
Infinite
The program will show compile-time error
Question 10
What will be the outpu tof the following program?
# include <stdio.h> int main() { int i = 0; for (i=0; i<20; i++) { switch(i) { case 0: i += 5; case 1: i += 2; case 5: i += 5; default: i += 4; break; } printf("%d ", i); } return 0; }
5 10 15 20
7 12 17 22
16 21
Compiler Error
There are 20 questions to complete.