Home » C Programming » Structures » Question
  1. What will be the output of the following C code?
    #include <stdio.h>
    struct
    {
    int i;
    char a;
    };
    int main()
    {
    struct stru;
    stru.i = 100;
    printf("%d\n", stru.i);
    }
    1. Compilation Error
    2. Garbage value
    3. Nothing
    4. 100
    5. None of these
Correct Option: A

Compilation Error

main.c:6:5: warning: unnamed struct/union that defines no instances
};
^
main.c: In function ‘main’:
main.c:10:9: error: ‘stru’ undeclared (first use in this function)
stru.i = 100;
^~~~
main.c:10:9: note: each undeclared identifier is reported only once for each function it appears in



Your comments will be displayed only after manual approval.