Govt Exams
Array access by index is O(1) because arrays use contiguous memory allocation, allowing direct access via base address + offset calculation.
char name[50] allocates exactly 50 bytes. The null terminator '\0' must fit within this 50-byte allocation.
In C, strings are null-terminated character arrays. The null character '\0' marks the end of the string.
Global arrays in C are automatically initialized to 0 by default. Only local arrays contain garbage values.
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.
int arr[5];
for(int i=0; i
Array values: arr[0]=0, arr[1]=1, arr[2]=4, arr[3]=9, arr[4]=16. Output is 1 4 16.
Linear search on unsorted array requires checking each element in worst case, giving O(n) time complexity.
char str[20];
strcpy(str, "Competitive");
strcat(str, " Exam");
printf("%s", str);
strcpy copies "Competitive" to str. strcat appends " Exam" to it, resulting in "Competitive Exam".
ptr[2] is equivalent to *(ptr+2), which points to the third element (index 2) of the array.