+ 1
What is difference between union and structure?
3 Respostas
+ 3
Structure is a collection of different types of elements on the single name
+ 3
for example take a structure and union  in the following way
struct
{
       int a;
       int b;
}c;
int main()
{
       /* scaning a and b
        structure uses different memory locations for a and b
        so after scaning we can print them in any way*/
     
       cin>>c.a;
       cin>>c.b;
       cout<<c.a;
       cout<<c.b;
}
if input: 2 3
   output:2 3
union
{
       int c;
       int d;
}e;
int main()
{
       /*in union it uses same memory location for all the variables in it */
               cin>>e.c;
               cout<<e.c;
               cin>>e.d;
               cout<<e.d;
     /* here in unions we should print or use the value immediately other wise the value will be replaced with the next value*/
}
##  if my solution is acceptable reply me with an vote###
+ 1
hii



