A word
- Which is a group of 16 contiguous bits or 2 bytes, is used to represent a natural number
- As we have studied, the maximum numeric value that can fit in a word is 65535
- Since the Byte is used only to represent a character, whenever you plan to use a number in your program, the minimum representation you should/must use is a word
An algebraic natural number
- Is also called an integer
The smallest integer you can store in a word
- Is declared with the short keyword followed by a name
A short integer is signed by default
- It can store a value that ranges from –32768 to 32767
- Here is an example program that uses two short integers (A-1):
Example of (A-1)
#include <iostream> using namespace std; int main() { short number1, number2; cout << "Enter a number between -32768 and 32767: "; cin >> number1; cout << "Enter another number: "; cin >> number2; cout << "\nThe numbers you entered were\n"; cout << "\tNumber 1: " << number1 << "\n"; cout << "\tNumber 2: " << number2 << "\n"; return 0; }
By default, a short integer
- Is signed
- You can also explicitly declare such a variable as a signed short
- Here is an example (A-2):
Example of (A-2)
signed short XCoord;
If the integer must be positive
- You should declared as an unsigned short
The unsigned short is used
- To identify a 16-bit positive integer whose value would range from 0 to 65535

Discussion
No comments for “Short Integers”