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


Please Help Members By Posting Answers For Below Questions

What is a virtual destructor? Explain the use of it?

543


What is encapsulation in C++? Give an example.

582


Differentiate between C and C++.

708


What are namespaces in c++?

589


What is the difference between structure and class?

552






What is meant by entry controlled loop?

656


What is purpose of abstract class?

582


What language does google use?

584


How do you differentiate between overloading the prefix and postfix increments?

586


Differentiate between an external iterator and an internal iterator?

570


What is the last index number in an array of 100 characters a) 100 b) 99 c) 101

586


Draw a flow chart and write a program for the difference between the sum of elements with odd and even numbers. Two dimensional array.

5895


What is public, protected, private in c++?

649


What is a flag in c++?

605


Why are arrays usually processed with for loop?

770