Govt Exams
arr[5] accesses the element at index 5, which is at memory address (arr + 5). Array name arr acts as a pointer to the first element.
malloc() returns a void pointer (void*), which can be cast to any data type pointer as needed by the programmer.
const int *ptr makes the data constant (const int * ptr). int * const ptr makes the pointer constant. The position of const matters.
The ternary operator syntax is: condition ? value_if_true : value_if_false. Option B is the only correctly formatted statement.
++x increments x to 6 (pre-increment), then x++ returns 6 and increments x to 7. So: 6 + 6 = 12. Post-increment returns the old value.
When passing a 2D array to a function, the number of columns must be specified, but the number of rows is optional. Option C is the standard correct syntax.
The asterisk (*) symbol is used to declare pointer variables. For example: int *ptr; declares a pointer to an integer.
Operator precedence: multiplication (*) is performed before addition (+). So: 3 * 2 = 6, then 5 + 6 = 11.
Variable names in C cannot start with a digit. They must begin with a letter (a-z, A-Z) or underscore (_). '123myVar' is invalid.
The correct syntax for a function pointer is: int (*ptr)(int, int);. The parentheses around (*ptr) are necessary to indicate that ptr is a pointer to a function, not a function returning a pointer. Option A declares a function returning an int pointer.