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 double in c++?

568


Define a nested class.

620


Please explain class & object in c++?

612


What is a static member?

623


How do you remove an element from a set in c++?

589






Is c++ the hardest programming language?

651


Differentiate between an array and a list?

713


which operator is used for performing an exponential operation a) > b) ^ c) none

614


When is the copy constructor called?

641


Which c++ operator cannot overload?

561


Describe Trees using C++ with an example.

618


A mXn matrix is given and rows and column are sorted as shown below.Write a function that search a desired entered no in the matrix .with minimum complexity 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

3254


Explain what you mean by a pointer.

642


What is istream and ostream in c++?

604


How do pointers work?

713