Friday 10 January 2014

Explain variable in C

Variable
A variable is a data name used for storing a data value.
Its value may change during execution.
It should not be a C keyword.
It may be a combination of uppercase and lowercase characters.
Ex-
sUm and SUM both are different.
It should start with a character not a digit
Declare variable
Its declaration should be done in declaration part of C program because it helps in allocating memory.
Syntax-
datatype variablename;
ex-
int age;
int a,b,c;
Initialize variable
Initialization and declaration of variable can be done in same line.
syntax-
datatype varaible = constant;
ex-
int y=2;
Constant variable
To make value of variable constant use keyword const before declaration
ex-
const int m=1;

No comments:

Post a Comment