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
Which of the following is not a valid declaration for main() a) int main() b) int main(int argc, char *argv[]) c) They both work
Why do we need constructors in c++?
What is binary object model?
Explain virtual class and friend class.
Write a program to find the Factorial of a number
Why do we need function?
Write a program which is required to process the time of a clock in hours and minutes, entered from the keyboard. With this program, there are two requirements for any data entered by a user: 1. The data must be of the correct type (in this case, two ints). 2. The data must be in the correct range: this means that, for the minutes, negative numbers and any number above 59 must be rejected; for the hours, negative numbers and any number above 23 must be rejected. Output error message for invalid data input. Output the time one and a half hour after the time input. i.e. Hour: 22 Min: 32 One and a half hour after 22:32 is 00:02
What does I ++ mean in c++?
What is algorithm in c++ programming?
What is the meaning of c++?
Comment on c++ standard exceptions?
what is a class? Explain with an example.
What is the difference between a template and a macro?
Can static member variables be private?
Which is best c++ or java?