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

Compilation Error

main.c: In function ‘main’:
main.c:6:27: error: invalid operands to binary + (have ‘int *’ and ‘int *’)
printf("%d", ptr1 + ptr2);



Your comments will be displayed only after manual approval.