C Programming - Complicated Declarations - Discussion

Discussion Forum : Complicated Declarations - True / False Questions (Q.No. 1)
1.
Does the data type of all elements in the union will be same.
True
False
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
7 comments Page 1 of 1.

Naresh said:   6 years ago
union U
{int a;
char ch;
int b;

};

In union, we can declare different/same data type.
But Memory allocates only for largest data member.

Rajeshree khedkar said:   8 years ago
Yes, nice @NIPA.

Aravind s unni said:   10 years ago
Pass a pointer.

Nipa said:   1 decade ago
Union is collection of different data types which store in same address.

Bruce said:   1 decade ago
@Sag: We don't have to declare the same datatype in union.

Here's a example from A First Book of ANSI C:

union
{
char *text;
double rate;
}uTax

Sag said:   1 decade ago
But in union we have to declare the same data type.

Nomulas said:   1 decade ago
False.

Because we can declare various data type variables according to our program convenient.

Post your comments here:

Your comments will be displayed after verification.