Home Subjects C Programming

C Programming

C language from basics to advanced placement prep

291 Q 10 Topics Take Mock Test
Advertisement
Difficulty: All Easy Medium Hard 221–230 of 291
Topics in C Programming
Q.221 Easy Control Flow
Which keyword is used to exit a loop prematurely in C?
A exit
B break
C return
D stop
Correct Answer:  B. break
EXPLANATION

The 'break' statement is used to exit or terminate a loop prematurely. 'exit' terminates the entire program, while 'return' exits functions.

Test
Q.222 Easy Control Flow
Which control structure allows checking multiple conditions in sequence using else-if?
A for loop
B switch statement
C if-else-if chain
D do-while loop
Correct Answer:  C. if-else-if chain
EXPLANATION

The if-else-if chain allows testing multiple different conditions sequentially. switch is used for a single expression with multiple values.

Test
Q.223 Easy Control Flow
What is the correct syntax for a for loop that iterates from 0 to 9?
A for(int i=0; i
B for(int i=0; i
C for(int i=1; i
D for(int i=0; i
Correct Answer:  B. for(int i=0; i
EXPLANATION

for(int i=0; i<10; i++) correctly iterates from 0 to 9 (10 iterations total). Using i<=10 would iterate 11 times, and starting from 1 would skip 0.

Test
Q.224 Easy Control Flow
In a switch statement, which keyword provides a default case if no cases match?
A else
B default
C otherwise
D case default
Correct Answer:  B. default
EXPLANATION

The 'default' keyword in a switch statement provides code to execute when no case values match the switch expression.

Test
Q.225 Easy Control Flow
Which control flow structure allows execution of code only if a certain condition is met?
A for loop
B if statement
C switch case
D while loop
Correct Answer:  B. if statement
EXPLANATION

The if statement executes a block of code conditionally. Loops repeat code, and switch cases are for multi-way branching based on a single expression.

Test
Q.226 Easy Control Flow
In the expression (x > 5) ? (y = 10) : (y = 20), what does y equal if x is 3?
A 10
B 20
C 3
D Undefined
Correct Answer:  B. 20
EXPLANATION

The ternary operator evaluates the condition (x > 5). Since 3 is not greater than 5, the expression evaluates to false, and the false part executes, setting y to 20.

Test
Q.227 Easy Control Flow
In a nested loop structure, which statement will skip only the inner loop's current iteration?
A break
B continue
C next
D skip
Correct Answer:  B. continue
EXPLANATION

The 'continue' statement skips the remaining statements of the current iteration and moves to the next iteration. In nested loops, it affects only the innermost loop.

Test
Q.228 Easy Control Flow
What is the primary difference between a while loop and a do-while loop?
A while checks condition before execution; do-while checks after
B do-while is faster than while
C while supports multiple conditions; do-while doesn't
D There is no functional difference
Correct Answer:  A. while checks condition before execution; do-while checks after
EXPLANATION

A do-while loop executes the body at least once before checking the condition. A while loop checks the condition first, so it may not execute at all.

Test
Q.229 Easy Control Flow
In C, which control flow statement is used to terminate a loop prematurely?
A break
B continue
C exit
D halt
Correct Answer:  A. break
EXPLANATION

The 'break' statement is used to exit or terminate a loop immediately. 'continue' skips the current iteration, 'exit' terminates the entire program.

Test
Q.230 Easy Control Flow
Which statement is used to skip remaining iterations and move to next iteration?
A skip
B continue
C next
D return
Correct Answer:  B. continue
EXPLANATION

continue is the C keyword that jumps to the next iteration of the loop.

Test
IGET
IGET AI
Online · Exam prep assistant
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