educative.io

About numbers in c language

How to write numbers in c language


Course: Learn C from Scratch - Free Interactive Course
Lesson: Constants - Learn C from Scratch

Hi @Mannat_Minhas,
Welcome to our Discuss community.

In C or any other programming language, you can write numbers by using different data types according to your need. Different data types support different number types and ranges. For example int data type can store values from -2,147,483,648 to 2,147,483,647. If you want to store a number outside of this range, you can use long int, which can store values from 9,223,372,036,854,775,808 to 9,223,372,036,854,775,807. You can also use long long int if you want to save a bigger number.

Similarly, if we talk about decimal/floating-point numbers, you can use the float data type, which can store decimal values. It can store values from 1.175494e-38 to 3.402823e+38. You can also use double for a higher range of decimal values.

In a coding environment, each value is stored, and operations are performed on it. The output value is also dependent on the type of input values. For example, if you divide two integer values, such as 5/2, it will return 2 as output instead of 2.5 because both inputs were integers, so the output is also an integer. If we divide 5.0/2 or 5/2.0, the output will be 2.5. So it is important to use appropriate data types when dealing with numbers in programming.

I hope you understand how to use numbers in C. If you’ve any other queries, feel free to ask. Thanks.