Home » C Programming » Pointers » Question
  1. What will be the output of the following C code?
     #include <stdio.h>
    int main()
    {
    int num[5] = {11, 21, 31, 41, 51};
    int ptr[5];
    ptr = num;
    printf("%d\n", ptr[2]);
    }
    1. Undefined behaviour
    2. Garbage value
    3. Compilation Error
    4. 51
    5. None of these
Correct Option: C

Compilation Error

main.c: In function ‘main’:
main.c:6:13: error: assignment to expression with array type
ptr = num;



Your comments will be displayed only after manual approval.