A variable is a name
that may be used to store a data value. Unlike constant, variables are
changeable, we can change value of a variable during execution of a program. A
programmer can choose a meaningful variable name. Example: average, height,
age, total etc.
Rules to define variable name:
1.
Variable name must be up to 8
characters.
2.
Variable name must not start with a
digit.
3.
Variable name can consist of alphabets,
digits and special symbols like underscore
_
.
4.
Blank or spaces are not allowed in
variable name.
5.
Keywords are not allowed as variable
name.
Declaration of variable:
Declaration of variables must be done
before they are used in the program. Declaration does two things.
1.
It tells the compiler what the variable
name is.
2.
It specifies what type of data the
variable will hold.
#include<stdio.h>
#include<conio.h>
void main()
{
int
a,b,sum; //variable declaration
a=10;
b=20;
sum=a+b;
printf("Sum is %d",sum);
getch();
}
No comments:
Post a Comment