C Programming - Structures, Unions, Enums - Discussion
Discussion Forum : Structures, Unions, Enums - Find Output of Program (Q.No. 2)
2.
What will be the output of the program ?
#include<stdio.h>
int main()
{
union var
{
int a, b;
};
union var v;
v.a=10;
v.b=20;
printf("%d\n", v.a);
return 0;
}
Discussion:
83 comments Page 9 of 9.
Ankita gaba said:
1 decade ago
If in above question a is initiallised with 20 and b with 10 then what will be the o/p?
Shikha said:
1 decade ago
All variable inside in the union share the same memory area so all modification done in the same memory hence answer is the last updated value i.e. 20.
Doni said:
1 decade ago
Srivdiya n Risbah answers are good.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers