Home » C Programming » Structures » Question
  1. What will be the output of the following C code?
    #include <stdio.h>
    struct Country
    {
    int code = 12;
    char name[20];
    };
    void main()
    {
    struct Country c;
    c.code = 15;
    printf("England");
    }
    1. Compilation Error
    2. Nothing
    3. England
    4. 15
    5. None of these
Correct Option: A

Compilation Error

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



Your comments will be displayed only after manual approval.