Home » C Programming » Pointers » Question
  1. What will be the output of the following C code?
    #include <stdio.h>
    struct car
    {
    int car_no = 12;
    char car_name[25];
    };
    void main()
    {
    struct car c;
    c.car_no = 10;
    printf("Audi");
    }
    1. 10
    2. Compilation Error
    3. Audi
    4. Garbage value
    5. None of these
Correct Option: B

Compilation Error

main.c:4:20: error: expected ‘:’, ‘,’, ‘;’, ‘}’ or ‘__attribute__’ before ‘=’ token
int car_no = 12;
^
main.c: In function ‘main’:
main.c:10:10: error: ‘struct car’ has no member named ‘car_no’
c.car_no = 10;



Your comments will be displayed only after manual approval.