-
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;
};
struct option1 fun();
int main()
{
struct option1 opt1 = {11};
struct option2 opt2 = {21, 31};
opt2 = fun();
printf("%d\n", opt2.m);
}
struct option1 fun()
{
struct option1 temp = {11, 21};
return temp;
}
-
- 21
- 11
- Compilation Error
- Undefined behaviour
- None of these
Correct Option: C
Compilation Error
main.c: In function ‘main’:
main.c:17:14: error: incompatible types when assigning to type ‘struct option2’ from type ‘struct option1’
opt2 = fun();