ProgrammingHardProduct-company MCQ pattern
What is f in the declaration int *(*f)(int); ?
- A. A function that takes an int and returns a pointer to a pointer to int
- B. A pointer to a function that takes an int and returns an int
- C. A pointer to a function that takes an int and returns a pointer to int
- D. An array of pointers to functions returning int
Correct answer: C. A pointer to a function that takes an int and returns a pointer to int
Start at the name and work outward: (*f) means f is a pointer; (int) after it means to a function taking int; int * at the left is the return type, a pointer to int.
More C Programming questions
- What is printed? c int a[] = {5, 10, 15}; int p = a; int x = p++; int y = (p)++; int z = ++p; printf("%d %d %d %d", x, y, z, a[1]);
- With 32-bit unsigned int, what is printed? c unsigned int x = 0; x--; printf("%u %d", x, x > 0);
- With ASCII and 4-byte int, what is printed? c char c = 'A'; c = c + 32; printf("%c %zu", c, sizeof(c + 1));
- What is printed? c char s[] = "abcdef"; char p = s, q = s + strlen(s) - 1; while (p < q) p++ = q--; printf("%s", s);
- What is printed? c struct A { int a[2]; }; struct B { int p; }; int v = 5; struct A x = {{1, 2}}, y; struct B m = {&v}, n; y = x; n = m…
- With 4-byte int and 8-byte double aligned on 8 bytes, what is sizeof(union U)? c union U { int i; double d; char c[10]; };