Question discussion

What will be the output of the following code?

358836Medium DSSSB TGT Computer Science 0 replies 0 views
0
What will be the output of the following code?
#include <stdio.h>
int main() {
    int arr[5] = {10, 20, 30, 40, 50};
    int (*p)[5] = &arr;
    printf("%d\n", *(*p + 3));
    return 0;
}
  • A40
  • B30
  • C20
  • DCompilation Error
Correct answer: A

Explanation

p is a pointer to the whole array, so *p is the array arr. *(*p + 3) is arr[3], which is 40.

Discussion 0

Nobody has replied yet. Start the discussion!