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
What is c++ coding?
What is size_type?
Will a recursive function without an end condition every quit, in practice a) Compiler-Specific (Some can convert to an infinite loop) b) No c) Yes
Define token in c++.
Why is c++ difficult?
Write a code/algo to find the frequency of each element in an array?
Write a program to interchange 2 variables without using the third one.
What are the benefits of c++?
What is guard code in c++?
What is the difference between object-oriented programming and procedural programming?
What are register variables?
What is stl containers in c++?
What do you mean by inheritance in c++? Explain its types.
Which coding certification is best?
What are put and get pointers?