C Arrays Quiz – 20 Questions with Answers
20 questions · 15 min · Medium
Test your knowledge of complicated C declarations, including pointers, arrays, functions, function pointers, pointer-to-pointer declarations, and the rules used to interpret complex declarations.
No sign-up needed · Last updated:
Score: 0 00:00
Create a free account to keep your scores and track your progress. It is optional.
20 questions · 15 min · Medium
15 questions · 12 min · Medium
15 questions · 12 min · Medium
15 questions · 12 min · Medium
15 questions · 12 min · Medium
15 questions · 12 min · Medium
B. A pointer to an integer
The `*` indicates that `p` is a pointer, and its pointed-to type is `int`.
C. A pointer to a pointer to an integer
The two `*` operators indicate two levels of indirection: `p` points to a pointer that ultimately points to an integer.
B. An array of 10 pointers to integers
The array subscript has higher precedence than `*`, so `a` is an array of 10 elements, with each element being a pointer to int.
B. A pointer to an array of 10 integers
The parentheses make `*p` bind together before the array subscript, so `p` is a pointer to an array of 10 integers.
B. A pointer to a function taking an int and returning int
The parentheses around `*fp` make `fp` a pointer to a function. The function accepts an int and returns an int.
B. A function taking no arguments and returning a pointer to int
Because `f(void)` is not parenthesized with `*f`, `f` is a function. Its return type is `int *`.
A. A function taking no arguments and returning a pointer to an array of 10 integers
Starting at `f`, `f(void)` makes it a function with no parameters. The `*` indicates that it returns a pointer, and `[10]` specifies an array of 10 integers.
B. An array of five pointers to functions taking double and returning int
The `[5]` makes `a` an array of five elements, and each element is a pointer to a function accepting a double and returning int.
A. Array subscripting `[]`
In declarators, postfix operators such as `[]` and `()` bind more tightly than the pointer `*`, unless parentheses change the grouping.
B. To control the binding and grouping of declarators
Parentheses can change how pointers, arrays, and functions are grouped, making declarations such as pointer-to-array or pointer-to-function possible.
B. A pointer to an array of 20 characters
The parentheses group `*p`, making `p` a pointer. The `[20]` then specifies that it points to an array of 20 characters.
B. A pointer to a function taking two integers and returning int
The parentheses around `*fp` make `fp` a function pointer. The pointed-to function accepts two int parameters and returns int.
A. A pointer to an array of 10 pointers to int
The declaration makes `p` a pointer to an array of 10 elements, where each element is a pointer to int.
B. Start at the identifier and follow the declarator outward, respecting parentheses
A useful approach is to start at the declared identifier and work outward, following arrays, functions, and pointers while respecting parentheses.
B. A pointer to a function taking an int and returning void
The parentheses around `*signal_handler` indicate that it is a function pointer. The function takes an int argument and returns void.