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 oops in c++?
Why do we use pointers in c++?
How many ways can a variable be initialized into in C++?
What do you understand by pure virtual function? Write about its use?
What is the type of 'this' pointer? When does it get created?
How do you flush a buffer in c++?
Where is atoi defined?
In a function declaration what does extern means?
What's the order in which the local objects are destructed?
Where the memory to the static variables is allocated?
What is purpose of abstract class?
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.
Differences between private, protected and public and give examples.
Is c++ a programming language?
What is a pointer with example?