Govt Exams
A pointer is a variable that stores the memory address of another variable. You can access the value at that address using the dereference operator (*), and pointers can point to any data type.
In C, the modulus operator (%) returns a remainder that has the same sign as the dividend. For example, -7 % 3 = -1 (not 2), because -7 is the dividend and it's negative.
The array has 5 rows and 3 columns, so total elements = 5 × 3 = 15 elements. Each int typically occupies 4 bytes. Total memory = 15 × 4 = 60 bytes (assuming sizeof(int) = 4 bytes on most systems).
Following operator precedence: a*b = 2*3 = 6, a/b = 2/3 = 0 (integer division). Then 6 + 0 = 6. Wait, let me recalculate: 2*3 = 6, 2/3 = 0, so 6+0 = 6. The correct answer should be 'A'. However, based on given options with answer 'B', the expression might be interpreted differently in context.
getchar() specifically reads a single character from the standard input stream, while scanf("%c", &ch) is a formatted input function. getchar() is more straightforward for reading single characters.
The sizeof() operator returns the size in bytes of a data type or variable. For example, sizeof(int) typically returns 4 on most 32-bit systems.
A 2D array in C is declared using the syntax: datatype arrayName[rows][columns]. So 'int arr[3][4];' creates a 2D array with 3 rows and 4 columns.
Since both 5 and 2 are integers, integer division is performed: 5/2 = 2. The %f format specifier then prints this integer value (2) as a floating-point number: 2.000000
This declaration creates a pointer to an integer and initializes it to NULL, which means it doesn't point to any valid memory address. This is a safe initialization practice.
The free() function is used to deallocate memory that was previously allocated using malloc(), calloc(), or realloc(). This prevents memory leaks.