Variable In C Language
Variable is used to store data. Variable is the name of the memory location .
let's see the syntax of declaration of variable:
Syntax: variable_type variable_nameExample: int y;
char ch;
float per;
In Above example int, char, float are the datatype and y, ch, per is the name of variable.
We can also provide value while we declare the varable as show below:
int y=10;
char ch='B';
float a=10.5, b=5.5;//Declaring 2 variable of float type
Rules of Declaring The Variable:
- Variable can have only aphabate and unerscore.
- Variable can not start with digit.
- White space is not allowed while you declaring the variable.
Valid Variable Name:
Invalid Variable Name:
1.Local Variable :
local variable declare inside of the function.
2.Global Variable:
A global variable declare outside of the function.
3.Static Variable:
Static means unchanged. A Variable declare with static keyword is called static variable.