Home » C Programming » Pointers » Question
  1. What will be the output of the following C code?
    #include <stdio.h>
    void main()
    {
    int arr[5] = {101, 201, 301, 401, 501};
    int *q1 = arr;
    int *q2 = &q1;
    printf("%d", (**q2));
    }
    1. Garbage value
    2. Compilation Error
    3. 101
    4. 102
    5. Same memory address
Correct Option: B

Compilation Error

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



Your comments will be displayed only after manual approval.