Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

How are virtual functions implemented in c++?

1121


Why do we use vector in c++?

1125


Explain rtti.

1139


What is the array and initializing arrays in c++?

1076


What is a storage class? Mention the storage classes in c++.

1072


What are namespaces in c++?

1139


Write a Program for read a line from file from location N1 to N2 using command line arguments. Eg:exe 10 20 a.c

1336


List down the guideline that should be followed while using friend function.

1117


Can notepad ++ run c++?

1152


Write a function that swaps the values of two integers, using int* as the argument type?

1082


What is isdigit c++?

1157


Explain dangling pointer.

1191


Why namespace is used in c++?

1118


Why do you use the namespace feature?

1135


Explain how we implement exception handling in c++?

1108