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

Compilation Error

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



Your comments will be displayed only after manual approval.