+ 5
Structure in c
The output is 11, could you explain why? #include <stdio.h> struct xyz{ int a; }; int main() { struct xyz obj1={1}; struct xyz obj2=obj1; printf("%d", obj2.a); obj2.a=100; printf("%d", obj1.a ); return 0; }
2 Respuestas
+ 9
obj1={1};
//the a int for obj1 is 1 so a=1
//Then
obj2=obj1;
//obj2 is also 1
printf("%d",obj2.a);
//print 1
.......
printf("%d",obj1.a);
/*print 1
so the global output is 11
if you add "\n" to the first print statement you get an output of:
1
1 /*
0
Hey ans??