GeekInterview.com
Series: Subject: Topic:
Question: 52 of 238

Short int and int

What is the difference between short int and int?
Asked by: chaitanyawithu | Member Since Mar-2008 | Asked on: Mar 26th, 2008

View all questions by chaitanyawithu   View all answers by chaitanyawithu

Showing Answers 1 - 4 of 4 Answers
windows_pal

Answered On : Aug 17th, 2008

View all answers by windows_pal

int has 16bits that is 2 bytes but short int has 8 bits that is 1 byte

  
Login to rate this answer.

hi i hope this will be useful for u.

in 16 bit processor (Ex: 8086), int data type contains 2 bytes(16 bits) and short contains 1 bytes(8 bits).

in 32 bit processor (80486), int data type contains 4 bytes(32 bits) and short contains 2 bytes(16 bits).

thanks
kannan R

  
Login to rate this answer.
sumit

Answered On : Feb 5th, 2012

Sorry to say that actually in most of C compiler short int is also of 16 bit and they are equivalent to each other.

  
Login to rate this answer.
jbode

Answered On : Feb 11th, 2012

View all answers by jbode

The general idea is that short "always" represents a 16-bit integer, whereas int represents whatever the native word size is for that particular architecture (16- or 32-bit). "Always" is in scare quotes for those oddball architectures that use weird word sizes. All you can really be guaranteed of is that sizeof (char) <= sizeof (short) <= sizeof (int) <= sizeof (long).

Per the C standard, both int and short must represent *at least* the range [-32767,32767] and the unsigned versions must represent *at least* the range [0,65535], so both must be *at least* 16 bits wide.

  
Login to rate this answer.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

Related Open Questions

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.