How’s going on? In my previous Post we saw that how to show something on the console using C program. Those who missed that episode you can click on the link below.
Let me ask you a question guys,
How will you get some input from the users in C program using console???
Okay, Generally we will use variables to get inputs from users.
What is variable?
In the terms of C programming, variable is an specific type of memory where we can store any data with the specific data type. Now you may have a question that what is data type?
Now come to the point,
In our daily life we always use and share some sorts of data. They could be a Name, A phone Number, Date of Birth or weight of something.
think about it, a Name, A phone Number or a date of Birth or any information actually contains some Letters and Numbers. So, Generally we can say that there are two types of Data. They are Numbers and Characters. Now again, Number has two types, Integer Numbers and Floating Numbers(Fractional Numbers).
So, we can state that , there are 3 types of data in C and they are:
- Letters/ Characters
- Integer Numbers
- Floating Numbers/ Fractional Numbers.
So, we will handle 3 types of data in C.
As we will use them in our C programming language then they will have some identifications and rules of use in the code. The identifiers and rules of use are given below:
The modifier of integer is %d | we say it ‘mod d’|When we will use them we will have to declare them in a variable. Example for integer data type and variable declaration is:
DECLARATION: int price = 10; USE: printf("The PRICE of your pen is %d", price);
The modifier of integer is %f | we say it ‘mod f’| When we will use them we will have to declare them in a variable. Example for float data type and variable declaration is:
DECLARATION: float price = 10.231110; USE: printf("The PRICE of your pen is %f", price);
The modifier of integer is %c | we say it ‘mod c’| When we will use them we will have to declare them in a variable. Example for character data type and variable declaration is:
DECLARATION: char letter = 'A'; USE: printf("The first LETTER of alphabet is: %c", letter);
Now home task:
- How will you declare an Integer variable with a value of 70?
- Declare a variable in float with value of 2.6412
- Print your name using character variables.
Try them and if you face any problem then knock me. I am always with my readers. That’s all for now. If you find it’s important and can help your friends then please share with them.