Question

explain in terms of c++ 1.     How to calculate the value of a short int and of...

explain in terms of c++

1.     How to calculate the value of a short int and of an int by looking at the values in hexadecimal.  Give an example for a short int and an int

2.     How the same bytes can represent such different values when read into the different data types

3.     Explain in your own words why the hexadecimal values for the chars, short ints and ints aren't in the same order

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Solution:

1)

32-bit system short data type occupies the memory of 2 bytes and int 4 bytes. so when we store a hexadecimal

suppose we have a hexadecimal value 0x100D5689

the given value is out of range of short int so only first four-digit will be stored and rest will be overflow

but int will be able to store all the values

short int=> 0x100D

converting: 1*16^3 + 0^16^2 + 0*16^1 + 13 * 16^0

= 4109

int=> 0x100D5689

the values is 269309577

The data in the memory is stored in little-endian or big-endian format.

2)

That is because of data overflow or the type in which data type they are represented.

3)

Because char is only 1 byte and short is 2 bytes whereas int is 4 bytes.

I hope this helps if you find any problem. Please comment below. Don't forget to give a thumbs up if you liked it. :)

Add a comment
Know the answer?
Add Answer to:
explain in terms of c++ 1.     How to calculate the value of a short int and of...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT