How to use long modifier?

We can apply the long modifier to the allowed data types just by adding it as a prefix in the normal variable declaration. For example:

int var;    // normal declaration
long int var;   // long int variable declaration

One thing to note here is that we cannot use the long modifier with any data type of our choice. In C, we can only use long with 3 datatypes which are as follows:

  1. long int
  2. long long int
  3. long double

C Long

In C, the long keyword is a datatype modifier that can be applied to the basic datatypes to increase the range and size of values their variables can store. For example, a long int variable can store integer values that range from -2,147,483,648 to 2,147,483,647 which is significantly greater as compared to the normal int data type, which can store integer values that range from -32,768 to 32,767 in the 16-bit compiler.

Similar Reads

How to use long modifier?

We can apply the long modifier to the allowed data types just by adding it as a prefix in the normal variable declaration. For example:...

1. long  int

When long is applied to an integer it creates a long int, which increases the range of values that int can store. The long int is used when the range of values exceeds the int data type....

2. long long int

...

3. long double

We can even apply the long modifier to long int to further increase the size of the data type. The long long int is often used when the range of values exceeds the long data type....

When to Use long in C?

...

Contact Us