ProgrammingVery hardGATE CS · Product company OA
What is f in the declaration below?
What is f in the declaration below?
int (*(*f)(int))[3];
- A. A function taking an int and returning a pointer to a pointer to an array of 3 ints
- B. An array of 3 pointers to functions taking an int and returning int
- C. A pointer to a function taking an int and returning a pointer to an array of 3 ints
- D. A pointer to a function taking an int and returning an array of 3 pointers to int
Correct answer: C. A pointer to a function taking an int and returning a pointer to an array of 3 ints
Start at f: (*f) makes it a pointer; (int) after it makes that a pointer to a function taking int; the * before that call says the function returns a pointer; [3] then says to an array of 3; int is the element type. Functions cannot return arrays, which rules out the third option outright.
More C Programming questions
- What is printed? c char s[10] = "abc"; char t[] = "xyz"; strncat(s, t, 2); printf("%s %zu %d", s, strlen(s), strncmp(s, "abcx", 4) == 0);
- What is printed? c char s[] = {"alpha", "beta", "gamma", "delta"}; char p = s; p += 2; printf("%c ", p); printf("%c ", ((p - 1) + 2))…
- What is printed? c int c = 0; int g(int n) { c++; if (n <= 2) return 1; return g(n - 1) + g(n - 2) + g(n - 3); } int main(void) { int r =…
- Assume 32-bit unsigned int. What is printed? c unsigned f(unsigned x) { return (x & 0x55555555u) << 1 | (x >> 1) & 0x55555555u; }…
- What is printed? c #define X 3 #define Y X 2 #if Y == 6 #define Z 1 #else #define Z 2 #endif printf("%d %d", Z, Y + 1 2);
- What is printed? c #define SHOW(x) printf(#x " = %d", x) int a = 3; SHOW(a 2 + 1);