C | Advanced Pointer | Question 4
#include <stdio.h> char *c[] = {"GeksQuiz", "MCQ", "TEST", "QUIZ"}; char **cp[] = {c+3, c+2, c+1, c}; char ***cpp = cp; int main() { printf("%s ", **++cpp); printf("%s ", *--*++cpp+3); printf("%s ", *cpp[-2]+3); printf("%s ", cpp[-1][-1]+1); return 0; } |
chevron_right
filter_none
(A) TEST sQuiz Z CQ
(B) MCQ Quiz Z CQ
(C) TEST Quiz Z CQ
(D) GarbageValue sQuiz Z CQ
Answer: (A)
Explanation: Let us first consider **++cpp. Precedence of prefix increment and de-reference is same and associativity of both of them is right to left. So the expression is evaluated as **(++cpp). So cpp points to c+2. So we get “TEST” as output. Note the de-reference operator twice.
Similarly, you may try other expressions yourself with the help of precedence table.
Quiz of this Question
Recommended Posts:
- C | Advanced Pointer | Question 3
- C | Advanced Pointer | Question 8
- C | Advanced Pointer | Question 9
- C | Advanced Pointer | Question 1
- C | Advanced Pointer | Question 7
- C | Advanced Pointer | Question 2
- C | Advanced Pointer | Question 10
- C | Advanced Pointer | Question 5
- Double Pointer (Pointer to Pointer) in C
- C++ | this pointer | Question 2
- C++ | this pointer | Question 4
- C++ | this pointer | Question 5
- C++ | this pointer | Question 1
- C++ | this pointer | Question 3
- What is a Pointer to a Null pointer



