Home » C Programming » Structures » Question
  1. What will be the output of the following C code?
    #include <stdio.h>
    struct option1
    {
    int m;
    int n;
    };
    struct option2
    {
    int m;
    int n;
    };
    int main()
    {
    struct option1 opt1 = {10};
    struct option2 opt2 = opt1;
    printf("%d\n", opt2.m);
    }
    1. Garbage value
    2. 0
    3. 10
    4. Compilation Error
    5. None of these
Correct Option: D

Compilation Error

main.c: In function ‘main’:
main.c:15:31: error: invalid initializer
struct option2 opt2 = opt1;



Your comments will be displayed only after manual approval.