Govt. Exams
Entrance Exams
Variables declared in a for loop's initialization (e.g., for(int i=0; ...)) have block scope limited to that loop. They are not accessible outside the loop.
Switch case values must be constant integral expressions (int, char, enum). Floating-point values and strings (in C89/C90) are not allowed.
The exit() function terminates the entire program and returns control to the operating system. break exits loops, and return exits functions.
A do-while loop executes the body at least once before checking the condition. Even if the condition is false, the body executes one time.
The correct syntax is (condition) ? (value_if_true) : (value_if_false). The condition comes first, followed by ? and then the true and false values separated by :.
The break statement exits only the innermost loop it is in. To exit multiple nested loops, you need multiple break statements or use goto.
A for loop with an empty body is valid syntax in C. The loop executes for the specified iterations but performs no operations in each iteration.
Without a break statement, execution continues to the next case (fall-through behavior). This is a common source of bugs if not intentional.
goto cannot jump across function boundaries. It can only jump within the same function to a labeled statement either forward or backward.
for (int i = 0; i < 5; i++) {
if (i % 2 == 0) continue;
printf("%d ", i);
}
continue skips even numbers. Loop prints only odd values: 1 and 3.