Variable:
A quantity whose value can be changed during
the execution of a program.
e.g
int a;
a=3;
a=5;
a=10;
- During the execution 2 bytes are reserved for variable a
- During execution memory location’s name remains same but data can be changed.
Rules
for writing variable name:
- First character must be an alphabet.
- ‘_’ can also be used as a first character.
- Blank spaces not allowed.
- Special characters can’t be used as a variable names
- Reserved words(e.g int , float, char, bool , if , else, switch etc ) can’t be used as a variable name.
- Variable name with one data type can’t be used for another data type.
- C is a case sensitive
language.
int sint Sthese are two different variablesAre they are Variable Names or not:
- blac k
- Naeem
- jack et-1
- Int
- Num_1
- If
- Char
- A
- Ab
- A1
- A 2
How to use const with variable:
1. const float pi=3.14;
2. Variable pi gets value 3.14 that can’t be
changed.
No comments:
Post a Comment