C Programming
Variables in C
A variable is a name of memory location that is used to store the data. We can change its value and reuse it.Example. int a; // a is the variable of type int.
flaot b; // b is the variable of type float.
Rules to Declare Variable
- Variable may be combination of digit(0-9), alphabet(a-z, A-Z) and under score(_).
- Variable name does not contain any blank space.
- Does not start with digit.
- Does not contain any reserve keyword.
int abc; // Right
int a2bc; // Right
int 2abc; // Wrong, Does not start with digit
int _abc; // Right
int a bc; // Wrong, Does not contain blank/white space
int float; //Wrong, Variable name must not be reserve keyword
Types of Variable in C
There are many types of variables in c:
- local variable
- global variable
- static variable
- automatic variable
- external variable