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 / ranjeet garodia
Jaroosh u r right while calculating the size...
but if u take size of int as 2 then astruct size will be
2+4+2=8
array = 1*10= 10
so c is correct
if size of int is 4, then
struct size will be 4+4+4= 12
then a is correct.
Is This Answer Correct ? | 1 Yes | 11 No |
Post New Answer View All Answers
What is a virtual destructor? Explain the use of it?
What is encapsulation in C++? Give an example.
Differentiate between C and C++.
What are namespaces in c++?
What is the difference between structure and class?
What is meant by entry controlled loop?
What is purpose of abstract class?
What language does google use?
How do you differentiate between overloading the prefix and postfix increments?
Differentiate between an external iterator and an internal iterator?
What is the last index number in an array of 100 characters a) 100 b) 99 c) 101
Draw a flow chart and write a program for the difference between the sum of elements with odd and even numbers. Two dimensional array.
What is public, protected, private in c++?
What is a flag in c++?
Why are arrays usually processed with for loop?