ProgrammingVery hardProduct company OA · GATE CS
Given int f(int); and int (*fp)(int) = f; which of these calls are valid? (i) fp(2) (ii) (*fp)(2) (iii) (**fp)(2) (iv) (&fp)(2)
- A. (i), (ii) and (iii) only
- B. (i) and (ii) only
- C. All four
- D. (ii) only
Correct answer: A. (i), (ii) and (iii) only
Dereferencing a function pointer gives a function designator, which immediately decays back into a pointer, so any number of * still calls f. &fp, however, is a pointer to the pointer variable, int (**)(int), which cannot be called.
More C Programming questions
- What is printed? c union U { int i; float f; } u = {3.9}; printf("%d", u.i);
- What is printed? c int i = 0, c = 0; while (i < 10 && ++c && i++ % 3 != 2); printf("%d %d", i, c);
- Given this allocation, which code frees everything without leaking or touching freed memory? c int m = malloc(3 sizeof m); for (int i = 0…
- With char a = "hi", b = "hi"; what can be said about the value of a == b?
- What is printed? c int c = 0; for (int i = 1; i <= 4; i++) for (int j = i; j <= 4; j += i) c++; printf("%d", c);
- Assume 16-bit unsigned short and 32-bit int. What is printed? c unsigned short v = 0x1234; unsigned short w = (unsigned short)(v << 8 | v…