Home Subjects C Programming

C Programming

C language from basics to advanced placement prep

499 Q 10 Topics Take Test
Advertisement
Difficulty: All Easy Medium Hard 351–360 of 499
Topics in C Programming
Q.351 Medium Control Flow
In nested loops, if an inner loop contains a break statement, what happens?
A Only the inner loop terminates; the outer loop continues
B Both inner and outer loops terminate
C The entire program terminates
D The break statement is ignored in nested loops
Correct Answer:  A. Only the inner loop terminates; the outer loop continues
EXPLANATION

The break statement only exits the innermost loop that contains it. It does not affect the outer loop's execution. The outer loop will continue its iterations normally.

Take Test
Q.352 Medium Control Flow
In a for loop with multiple break statements in different conditions, which break will be executed?
A Only the first break encountered
B All break statements execute
C The break statement whose condition is true
D None of them execute unless the loop condition fails
Correct Answer:  C. The break statement whose condition is true
EXPLANATION

Only the break statement whose associated if condition evaluates to true will be executed, exiting the loop immediately.

Take Test
Q.353 Medium Control Flow
What is the output of this code?
char ch = 'B';
switch(ch) {
case 'A':
case 'B':
case 'C': printf("Vowel");
break;
default: printf("Consonant");
}
A Vowel
B Consonant
C No output
D Compilation error
Correct Answer:  A. Vowel
EXPLANATION

ch='B' matches case 'B', which has no statements. Execution falls through to case 'C' which has no statements, then prints 'Vowel' and breaks.

Take Test
Q.354 Medium Control Flow
In C programming, what is the difference between break in a loop and break in a switch statement?
A There is no difference
B break in switch exits all nested structures, break in loop exits only the loop
C break in loop exits the loop, break in switch exits only the current case
D break in switch works only with integers, break in loop works with all types
Correct Answer:  C. break in loop exits the loop, break in switch exits only the current case
EXPLANATION

Both break statements exit their immediate enclosing structure. In loops, break exits the loop; in switch, break exits the switch block.

Take Test
Q.355 Medium Control Flow
Which control structure would be most efficient to validate if a number is within one of several specific values?
A Multiple if-else if chains
B Nested if statements
C switch statement
D do-while loop with break
Correct Answer:  C. switch statement
EXPLANATION

switch statement is optimized for multiple discrete value checks and is more readable than chained if-else statements.

Take Test
Q.356 Medium Control Flow
What will be the output of this code?
int n = 5;
switch(n) {
case 4: printf("Four");
case 5: printf("Five");
case 6: printf("Six");
break;
default: printf("Other");
}
A Five
B FiveSix
C FourFiveSix
D Other
Correct Answer:  B. FiveSix
EXPLANATION

n=5 matches case 5. Without break, it falls through to case 6 before encountering break. Prints 'FiveSix'.

Take Test
Q.357 Medium Control Flow
How many times will the loop execute?
int i = 0;
while(i++ < 5) {
printf("%d ", i);
}
A 4 times
B 5 times
C 6 times
D Infinite loop
Correct Answer:  B. 5 times
EXPLANATION

i++ returns value before incrementing. Condition checks: 0<5(T), 1<5(T), 2<5(T), 3<5(T), 4<5(T), 5<5(F). Loop runs 5 times.

Take Test
Q.358 Medium Control Flow
What will this code output?
for(int i = 1; i
A 1\n12\n123
B 123\n123\n123
C 1\n2\n3
D 111\n222\n333
Correct Answer:  A. 1\n12\n123
EXPLANATION

Nested loop: outer loop runs 3 times, inner loop runs i times. Prints 1, then 12, then 123 on separate lines.

Take Test
Q.359 Medium Control Flow
Which of the following statements about switch case is TRUE?
A break is mandatory in every case
B default case must be the last case
C Multiple cases can execute if break is missing (fall-through)
D Switch can only work with integer values
Correct Answer:  C. Multiple cases can execute if break is missing (fall-through)
EXPLANATION

Without break, execution falls through to the next case. Default can be anywhere, and modern C allows switch with other types.

Take Test
Q.360 Medium Control Flow
What is the output?
int x = 10;
while(x-- > 5) {
printf("%d ", x);
}
A 9 8 7 6 5
B 10 9 8 7 6
C 9 8 7 6
D 10 9 8 7 6 5
Correct Answer:  C. 9 8 7 6
EXPLANATION

x-- returns the value before decrementing. Loop runs while value > 5: prints 9,8,7,6 (when x becomes 5, condition fails).

Take Test
IGET
iget AI
Online · Ask anything about exams
Hi! 👋 I'm your iget AI assistant.

Ask me anything about exam prep, MCQ solutions, study tips, or strategies! 🎯
UPSC strategy SSC CGL syllabus Improve aptitude NEET Biology tips