How to use the long data type in the C language?
In C language, long is an integer type used to represent a larger range of whole numbers. This type can be used in the following ways:
- Declare a long variable.
long num;
- Assign a value to the long variable.
num = 1234567890;
- Perform calculations using a long variable.
long result = num * 2;
- Display the value of the long variable:
printf("%ld\n", num);
“%ld” is a placeholder used for formatting long data types in output.
It should be noted that the range of long data type may vary depending on the platform. On most platforms, the range of long data type is usually between -2,147,483,648 and 2,147,483,647 (32-bit system). If a larger range of integers is needed, you can use the long long data type.