variable used in the program should be declared to the compiler.
This declaration tells us two
things:
1. Tells the compiler the name of the variable
2. Tells the type of variable that it holds
Syntax
variable-name1, variable-name1, … variable-name-n;
For example,
int a;
float k;
double j;
Also, we can initialize these variables if needed:
int a= 10;
float k = 80.80;
double j = 90.89765;
When we have many variables to be declared, they are separated by commas and must end with a
semicolon.
Rules for Forming Variable Names
1. A variable name must start with a letter.
2. A variable name is a combination of 1 to 8 letters, digits, or underscores. Some compilers
allow it up to 40 characters.
3. A variable name must not have any commas or blank spaces.
4. A variable name must not have any special symbols other than underscores.
Do'stlaringiz bilan baham: |