Variables, Datatypes used C-Program


As said in the previous tutorial, in every C-Program we use a header file and inside those files we have our basic commands.



Datatypes

There are 3 main Datatypes that are used in C-Program:

1. int
int is used to assign a variable with natural numbers. (From 0 to infinity)

2. float
float is used to assign with Decimal numbers. (For example, 45.2)

3. char
char is used to assign variables with Characters (called as strings)



Variables

Variables represent a memory location in which we can store data of any type.
A vairable can be assigned with any word or character.



How to assign variables with datatypes?

First we write the "Datatype" and then the "Name" that you want to give the variable.

We will take an example of assigning a variable with a name add having a datatype of integer.

                    
                        int add;
                    
                

As you can see in the above line, we have successfully assigned a integer variable.
Same we can do with other datatypes as well.

Note

If we are assigning a variable with a int datatype, then we can only assign natural numbers.
We cannot assign float numbers like 3.4,2.5,etc or even characters in it.
For this we need to define that specific datatype.



Conclusion:

Hence we learned what are Datatypes, Variables, and how can we assign different variables with different datatypes.



What we will learn next ?

Next we will learn how to implement these variables and datatypes and how can we perform basic logical operations with these.