Govt. Exams
Entrance Exams
The 'break' statement is used to exit or terminate a loop prematurely. 'exit' terminates the entire program, while 'return' exits functions.
The if-else-if chain allows testing multiple different conditions sequentially. switch is used for a single expression with multiple values.
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.
The 'default' keyword in a switch statement provides code to execute when no case values match the switch expression.
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.
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.
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.
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.
The 'break' statement is used to exit or terminate a loop immediately. 'continue' skips the current iteration, 'exit' terminates the entire program.
continue is the C keyword that jumps to the next iteration of the loop.