Control Structures - Study Mode

[#1] The type of the controlling expression of a switch statement cannot be of the type ........
Correct Answer

(D) float

[#2] What's wrong in the following statement, provided k is a variable of type int? for ( k = 2, k <=12, k ++)
Correct Answer

The increment should always be ++k .

Explanation

Solution: In for loop the three statements parts are separated by two semicolons which are missing here.

[#3] Which control structure is used to repeatedly execute a block of code in C?
Correct Answer

(D) while loop

[#4] In C, what is the purpose of the 'break' statement within a loop?
Correct Answer

(C) Terminate the loop and exit it

[#5] What is the purpose of the 'else' statement in C's 'if-else' control structure?
Correct Answer

(B) Execute the 'else' block