if we use short then we can save memory.But eventhough if we use short it occupies 2 bytes of memory so how can we save memort?

Recommended Answers

All 2 Replies

there is no guarentee that a short will occupy 2 bytes of memory. The only thing we can be sure of is that char <= short <= int <= long. Notice that on some os all could be the same size.

On operating systems where short is 2 bytes and int/long are 4 bytes, using short will save 2 bytes over using int or long. However it may not be possible to use short if the value you want to store will not fit in a short.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.