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 the best c++ book?
What are the uses of typedef in a program?
What is pure virtual function?
Is c++ map a hash table?
Explain abstraction.
What methods can be overridden in java?
A company pays its salespeople on a commission basis. The salespeople receive $200 per week plus 9 percent of their gross sales for that week. For example, a saleperson who sells $5000 worth of merchandise in a week receives $200 plus 9 percent of $5000, or a total of $650. You have been supplied with a list of items sold by each salesperson. The values of these items are as follows: Item Value A 239.99 B 129.75 C 99.95 D 350.89 Write a program that inputs one salesperson's items sold in a week (how many of item A? of item B? etc.) and calculates and displays that salesperson's earnings for that week.
Which software is best for programming?
What is the two main roles of operating system?
Does dev c++ support c++ 11?
Can I learn c++ without knowing c?
Is eclipse good for c++?
Why do we use pointers in c++?
What is c++ prototype?
Explain what you mean by a pointer.