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

Name the implicit member functions of a class.

700


Declare a class vehicle and make it an abstract data type.

625


What are the various situations where a copy constructor is invoked?

709


Write a program for Divide a number with 2 and Print the output ( NOTE: Check for divide by zero error).

727


Do we have to use initialization list in spite of the assignment in constructors?

670






What is class syntax c++?

711


How do c++ struct differs from the c++ class?

701


Is sorted c++?

680


What is the use of 'using' declaration in c++?

721


What is binary search in c++?

684


What is the use of string in c++?

635


What is the basic of c++?

706


Differentiate between the message and method in c++?

688


What is ifstream c++?

660


How does code-bloating occur in c++?

836