In this article, we will discuss short and long-type modifiers.
Short type modifier in C:
- Short type modifier applies only to the int datatype. After applying the short type modifier the size of an int data type will be 2 Bytes.
- If you won’t specify a datatype with a ‘short’ type modifier, by default it will be treated as ‘short int’. i.e. Both short a; & short int a; are the same.
- The size of the short-type modifier is 2 Bytes & its range is
(-2 (power (16-1))-1) to (2 (power (16 -1))-1)
.
Valid use of short type modifier in C:
- short a;
- short int a;
Invalid use of short type modifier in C
- short char b;
- short float b;
- short double c;
Long Type modifier in C
The size of the long-type modifier varies across different compilers. In a 32-bit C compiler, it is 4 bytes and in a 64-bit compiler, it is 8 bytes.
Long type modifier is only applicable to int and double data types.
If we won’t specify the data type with a long type modifier, By default, it will be treated as a long int. Therefore both long and long int are the same.
The range can be calculated by using the formulae (-2 (power(N - 1)) - 1) to (2 (power (N - 1)) - 1)
. Here, N = 8 x Size of datatype
.
Valid use of long type modifier in C:
- long a;
- long int a ;
- long double a;
Invalid use of long type modifier in C:
- long short a;
- long char a ;
- long float a;
The below table depicts, how the size of int
and double
data types vary across different compilers after applying the long
and short
type modifiers.

Example program on short and long type modifiers.
#include <stdio.h>
int main()
{
short value = 23;
short int value2= 45;
printf("The size of short variable is %d Bytes\n", sizeof(value));
printf("The size of short int variable is %d Bytes", sizeof(value2));
return 0;
}
Output:
The size of the short variable is 2 Bytes
The size of the short int variable is 2 Bytes
Explanation:
sizeof()
is a special operator & it is used to find the size of the data type.- ‘
\n
‘ is a new line character. It will take the cursor to the new line. - In the above program, both “
short
” & “short int
” variable is of 2 Bytes.