Home » C Programming » Pointers » Question
  1. What will be the output of the following C code?
    #include <stdio.h>
    void main()
    {
    int array[4] = {11, 12, 13, 14};
    int *ptr1 = array;
    int *ptr2 = &ptr1;
    printf("%d", (**ptr2));
    }
    1. 11
    2. 12
    3. 13
    4. 14
    5. Compilation Error
Correct Option: E

Compilation Error

main.c: In function ‘main’:
main.c:6:21: warning: initialization from incompatible pointer type [-Wincompatible-pointer-types]
int *ptr2 = &ptr1;
^
main.c:7:23: error: invalid type argument of unary ‘*’ (have ‘int’)
printf("%d", (**ptr2));



Your comments will be displayed only after manual approval.