Q BgQuestion:

      
Scholar
Karma Points: 235
Respect (89%):
posted by  John786 on 11/1/2009 5:30:02 PM  |  status: Closed  |  Earned Karma: 235

Minimum Size in C++ (urgent)

Course Textbook Chapter Problem Needs by
N/A N/A N/A N/A 11/4/2009 at 4:00:00 PM
Question Details:
Give the minimum size of each of the following C++ types. char has 1 byte, short has 2 bytes, int & float has 4 bytes, double & long has 8 bytes, pointer has 4 bytes.

a) struct sl_type {
long i;
char ch;
int *ip;
};

b) union u_type {
float f;
char *cp;
short s[3];
double d;
};

c) struct s2_type {
u_type u;
float *fp;
long n;
char c[15];
sl_type t;

};


AAnswers:

Answer Question Ask for clarification
Oracle
Karma Points: 31,937
posted by rapunzel on 11/1/2009 8:35:27 PM  |  status: Live
Asker's Rating: Lifesaver   
Response Details:
please rate - thanks

Give the minimum size of each of the following C++ types. char has 1 byte, short has 2 bytes, int & float has 4 bytes, double & long has 8 bytes, pointer has 4 bytes.

a) struct sl_type {
long i;                                8 bytes
char ch;                        +   1
int *ip;                          +   4
};                                    13  bytes

b) union u_type {
float f;                                 4 bytes
char *cp;                          +4
short s[3];              +2(3)=  6
double d;                            8
};                                      22 bytes

c) struct s2_type {
u_type u;                      22 bytes
float *fp;                  +    4
long n;                       +   8   
char c[15];                +  15
sl_type t;                   +  13
                                    62 bytes
};



Note to all members 1. Please 1 question per post 2. Show respect to your fellow members by rating all answers. 3. When rating remember that the first answer is not necessarily the best answer. 4. When answering questions, explain what you are doing, so that the asker will learn, don't just give a meaningless number. 5. Your answers should be your work. Don't copy from another member, this is Karma abuse and possible disciplinary actions against you. and GOOD LUCK to you all!!
Answer Question Ask for clarificarion

Join Cramster's Community

Cramster.com brings together students, educators and subject enthusiasts in an online study community. With around-the-clock expert help and a community of over 100,000 knowledgeable members, you can find the help you need, whenever you need it. Join for free today » How Cramster is different from tutoring »