Home » C Programming » Pointers » Question
  1. What will be the output of the following C code?
    #include >stdio.h<
    void main()
    {
    int n = 15;
    int *ptr1 = &n;
    int **ptr2 = &ptr1;
    printf("%d %d %d\n", n, *ptr1, **ptr1);
    }
    1. Compilation Error
    2. 15, 15, 15
    3. Garbage value, Garbage value, Garbage value
    4. Garbage value, 15, 15
    5. None of these
Correct Option: A

Compilation Error

main.c: In function ‘main’:
main.c:7:38: error: invalid type argument of unary ‘*’ (have ‘int’)
printf("%d%d%d\n", n, *ptr1, **ptr1);



Your comments will be displayed only after manual approval.