Govt Exams
The syntax char *str[5] declares an array of 5 pointers, each pointing to a character (or string). The brackets bind tighter than asterisk.
Option A is valid - 2D arrays can be initialized with all elements in a single brace. Options B and C are invalid as at least one dimension must be specified.
'Hello' has 5 characters plus 1 null terminator (\0), making total 6 bytes.
Array names decay to pointers to their first element in most contexts. 'arr' is equivalent to &arr[0] and cannot be reassigned.
int arr[5]; for(int i=0; i
Loop runs from i=0 to i=4, executing 5 times total. All array elements are initialized to 0.
int occupies 4 bytes. Array size is 3×4 = 12 elements. Total: 12 × 4 = 48 bytes.
strlen() is the standard library function defined in string.h that returns the length of a string excluding the null terminator.
A char array of size 50 can store maximum 49 characters because the last position is reserved for the null terminator '\0'.
int arr[] = {10, 20, 30, 40};
int *p = arr;
printf("%d", p[2]);
p points to arr[0]. p[2] is equivalent to *(p+2), which points to arr[2] = 30.
int arr[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
printf("%d", arr[1][2]);
arr[1][2] refers to row 1, column 2, which contains 6.