Variable Declaration
The memory area used for storing the input data or intermediate data , is called variable.
There are some rules to declare the variables in C language:
1. Must be start with alphabet.
2. Special character is not allowed except _(Underscore).
3. Variable may be alphanumeric.
4. Variable name must be different from keywords used in C language like printf, scanf,eof etc.
The syntax for variable declaration is
1. <datatype><space> <variablename>
2. <datatype><space> <variablename>=<value>
for example: int x;
int Num=10;
char str;
char str[45];
Datatype used in C language
A datatype is used to instruct the compiler that what type of data will be stored in variable. Different type of datatype are used in C language is:
1. int(2 to 4 byte)
2. float(4 Byte)
3. cha(1 byte)
4. double(8 byte)
5. long(4 Byte)
int and long datatype is used to store the integer , float and double are used to store the real values and char is used to store the character values.
Example:
int a,b;
char ch;
float Num;
No comments:
Post a Comment