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
Is c++ the hardest programming language?
How will you call C functions from C ++ and vice-versa?
What are the basic data types used in c++?
What is function declaration in c++ with example?
What are the extraction and insertion operators in c++? Explain with examples.
What is object in c++ wikipedia?
Show the declaration for a pointer to function returning long and taking an integer parameter.
Write a Program for read a line from file from location N1 to N2 using command line arguments. Eg:exe 10 20 a.c
What is the difference between an external iterator and an internal iterator?
Define a pdb file.
Why is c++ still best?
If a header file is included twice by mistake in the program, will it give any error?
What is setw manipulator in c++?
What are member functions used in c++?
Explain the difference between using macro and inline functions?