Govt Exams
arr creates a modifiable array copy of the string. ptr points to a string literal (read-only in memory). Modifying *ptr leads to undefined behavior.
strcpy() doesn't check dest buffer size, making it unsafe. It can cause buffer overflow if src is larger than dest. Modern compilers recommend strncpy() or strlcpy().
arr[0][0] is a 1D array of 5 integers. Each int is 4 bytes, so total is 5×4=20 bytes.
char str[] = "GATE2025";
for(int i=0; str[i]!='\0'; i++)
if(i%2==0) printf("%c", str[i]);
Indices: 0(G), 2(T), 4(E), 6(2). Even indices are printed: G, T, E, 2 -> "GTE2". Wait, let me recount: G(0), A(1), T(2), E(3), 2(4), 0(5), 2(6), 5(7). Even: G, T, 2, 2. Actually "GAE2" matches indices 0,2,4 which is GTE2. Let me verify: index 0=G, 2=T, 4=2, 6=5. So GTE2. But option shows GAE2. Rechecking: str="GATE2025": G(0)A(1)T(2)E(3)2(4)0(5)2(6)5(7). Even indices: 0,2,4,6 = G,T,2,2. Hmm, this should be GT22 but that's not an option. Let me reconsider the string. Actually "GATE2025" = G-A-T-E-2-0-2-5. Indices 0,2,4,6 = G,T,2,2. Since this doesn't match, the closest is checking if question meant something else. Looking at option C "GAE2", this would be indices 0,1,2,4 which isn't all even. There might be a typo in the original. The answer should logically be "GT22" for even indices.
2D array is stored contiguously in memory. 3x3 array has 9 elements total, accessible as a 1D array of 9 elements.
Without a base case, recursion never terminates. Each function call pushes data onto the stack. Eventually, the stack memory is exhausted, causing a stack overflow error. This is a runtime error, not a compile-time error.
When an array is used as a function parameter, it undergoes array-to-pointer decay, converting to a pointer to the first element. This is why size information is lost.
A callback is a function pointer passed to another function, which then invokes it at some point. Callbacks are essential for event-driven programming and implementing custom behavior.
Variadic functions must have at least one fixed parameter before the ellipsis (...). This allows the function to know where variadic arguments begin. Type checking is NOT enforced for variadic arguments.
The restrict keyword informs the compiler that the pointer is the sole means of accessing the data it points to, allowing for optimization. It's a hint for compiler optimization.