Govt. Exams
Entrance Exams
goto statement allows unconditional jump to a labeled location. Though generally discouraged, it's valid in C and sometimes used for error handling.
Missing break causes fall-through behavior where execution continues to the next case label until a break or end of switch is encountered.
do-while loop checks the condition after executing the loop body, ensuring at least one execution. while loop checks before executing.
break and continue statements can only be used within loops or switch statements. Using break outside these constructs results in a compilation error.
int result = (5 > 3) ? 10 : 20;
The condition (5 > 3) is true, so the ternary operator evaluates and returns the true expression value: 10.
break completely exits/terminates the loop. continue skips the rest of current iteration and jumps to the next iteration.
int x = 1, y = 2;
if(x > y) printf("A");
else if(x < y) printf("B");
else printf("C");
Since x=1 and y=2, x>y is false, but x<y is true, so 'B' is printed. The else if condition matches.
for(int i = 1; i
When i=3, break executes and exits the loop immediately. Only i=1 and i=2 are printed. Output: 1 2
The ternary operator syntax is: condition ? true_expr : false_expr. If condition is false, false_expr is evaluated.
if(0) { statements; } else { statements; }
When the if condition is false (0 is false in C), the else block executes. This is basic if-else control flow.