Integers, long and short

C offers a variation of the integer data type that provides what are called short and long integer values. The intention of providing these variations is to provide integers with different ranges wherever possible. Though not a rule, short and long integers would usually occupy two and four bytes respectively. Each compiler can decide appropriate sizes depending on the operating system and hardware for which it is being written, subject to the following rules:

  1. shorts are at least 2 bytes big.
  2. longs are at least 4 bytes big.
  3. shorts are never bigger than ints.
  4. ints are never bigger than longs.

long variables which hold long integers are declared using the keyword long, as :

long int i ;
long int abc ;

long integers cause the program to run a bit slower, but the range of values that we can use is expanded tremendously. The value of a long integer typically can vary from -2147483648 to +2147483647. More than this you should not need unless you are taking a world census.
 
If there are such things as longs, symmetry requires shorts as well—integers that need less space in memory and thus help speed up program execution. short integer variables are declared as :

short int j ;
short int height ;

C allows the abbreviation of short int to short and of long int to long. So the declarations made above can be written as :

long i ;
long abc ;
short j ;
short height ;

Naturally, most C programmers prefer this short-cut.
 
Sometimes we come across situations where the constant is small enough to be an int, but still we want to give it as much storage as a long. In such cases we add the suffix ‘L’ or ‘l’ at the end of the number, as in 23L.