What would be the output of the following progam?union check{ char name[10]; int age;}A;void main(){ printf("Enter your name: "); scanf("%s",&A.name);printf("Enter your age: "); scanf("%d",&A.age);printf("Name=%s Age=%d",A.name,A.age);}

Questions by jitudash

Showing Answers 1 - 3 of 3 Answers

kalaivanan

  • Sep 21st, 2007
 

ans would be the name &string

  Was this answer useful?  Yes

Since it is a union so both age and name will share same storage area. output will actually depend which data member was modified last. So in this case, since age is the last to be modified (entered), so name will come as character value of age.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions