Chpter 3 variables and datatypes in c
In the last chapter we have learn about the general structure of c programming
Now we will learn about the variables and datatypes
In the last chapter we have learn about the general structure of c programming
Now we will learn about the variables and datatypes
variables
variables are like bag. where we can store the value in the form of integer, floating value or characters
suppose you want to store books, clothes and electronic gadgets. you will seperate them by different bags.
some rules for the variable declaration
- variables should be start from character or _.
- variables cannot declared by begining with integer value
- can not use any symbol exept _
- we cannot named variables instead of reserved keywords
these keywords are as follow
these are special keywords in c
so we need to skip them
Datatypes in c
as we are storing different things in different bags we store the value
so this types are
int
char
float
we will study about this three datatypes only
we will continue remaining datatype at later.
int it stores the value in form of integer
char it stores the value in the form of character
float it stores the value in the form of floating value like 7.9
so we will write a program for better understanding
before writing a program we need to understand some concepts
library functions
these are predefined functions used for performing some task
some examples like
printf it is used for the printing the value assigned in the double quote of printf function
scanf this function is used for taking inputs from the user
commets
comments are used for understanding of the project in the coding. suppose you have written a code six
months ago now you are reading it again. then you will get difficulties to understand the codes in c
so here comments are useful. this part is ignored by the compiler
for single line comments are used as //
for multiple lines comments are used as /*........*/
Note: You can make constant for variables in c. Means one you assigned the value in c. you can not change it.
for that you needs to add const keyword before declaring variable
code |
output |
home work programe
write a program for printing the value given by the user
0 Comments