Which uses less memory?
a)
struct astruct
{
int x;
float y;
int v;
};

b)
union aunion
{
int x;
float v;
};

c)
char array[10];

Answer Posted / jaroosh

And the explanation for the above answer is :
union has the size of the biggest type of its member, so
here its size is 4, while structs size is 4 + 4 + 4 = 16,
and arrays size is 1 * 10 = 10.

Is This Answer Correct ?    10 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain function overloading and operator overloading.

626


Can I learn c++ without knowing c?

593


What is the sequence of destruction of local objects?

558


What is the use of volatile variable?

601


Can a list of string be stored within a two dimensional array?

578






What is meant by entry controlled loop? What all C++ loops are exit controlled?

572


Is it possible to use a new for the reallocation of pointers ?

601


Why iomanip is used in c++?

639


What is an iterator class in c++?

601


Is c++ a good beginners programming language?

584


What is the use of endl in c++ give an example?

617


What are manipulators used for?

613


how to access grid view row?

1814


Why do we use pointers in c++?

591


What is the difference between ++ count and count ++?

585