Home » C Programming » Pointers » Question
  1. What will be the output of the following C code?
    #include <stdio.h>
    int main()
    {
    int array[3] = {16, 17, 18};
    int *p = &array[1];
    float m = 1;
    p = p + m;
    printf("%d\n", *p);
    }
    1. 16
    2. 17
    3. 18
    4. Compilation Error
    5. Garbage value
Correct Option: D

Compilation Error

main.c: In function ‘main’:
main.c:7:15: error: invalid operands to binary + (have ‘int *’ and ‘float’)
p = p + m;



Your comments will be displayed only after manual approval.