Govt Exams
The while loop starts with i=0. It prints 0, then increments i to 1, prints 1, increments to 2, prints 2, increments to 3, and the condition i<3 becomes false, so the loop terminates. Output: 0 1 2
The 'break' statement is used to exit or terminate a loop or switch statement immediately. It transfers control to the statement following the loop or switch.
The increment (++) and decrement (--) operators have the highest precedence among all operators in C, followed by unary operators, then multiplicative, additive, and so on.
When ptr points to the array arr, ptr[1] is equivalent to *(ptr+1), which accesses the second element of the array, which is 2.
The volatile keyword tells the compiler that a variable's value may change unexpectedly (e.g., due to hardware, interrupts, or other threads), preventing compiler optimizations that assume the value doesn't change.
Both are valid syntax. Option A declares an anonymous structure with immediate variable instantiation. Option B declares a named structure type that can be used later to create variables.
A static variable inside a function is initialized only once and retains its value between successive function calls. It has memory allocated in the data segment, not the stack.
fgets() is the safe way to read strings including spaces. scanf("%s") stops at whitespace, gets() is deprecated and unsafe due to buffer overflow risks.
This is XOR swap algorithm. Step 1: a = 10^20. Step 2: b = (10^20)^20 = 10. Step 3: a = (10^20)^10 = 20. Result: a=20, b=10 (values are swapped).