1. Identifier
2. Keywords3. Variables
Identifier
The name given to program elements often to variables. The rules of giving name are:
- Characters (a-z, A-Z) and numbers (0-9) and underscore( _ ) can only be used.
- An identifier must start from a character or underscore we can not start the name with numbers.
- As we know that C++ is a case sensitive language so case is distinguishable i.e. ID and id can be used as separate identifiers.
- We can not use a keyword as an identifier.
Variable_One
_variable2
this_is_your_identifier
Illegal Identifiers
1variable
:variable
this is your identifier
Keywords
These are standard identifier that are predefined in C++.
Rules of Keywords:
- Keywords can be only used for their defined purpose.
- Keywords can't be used as an identifier.
- Keywords can't be used as a variable name.
Some common keywords are: void, long, else, do, goto, char, int etc.
Variables
Variable is the name given to a specific memory location to store some values, the size is depends on the type of the variable which is declared by the programmer.
The syntax of declaring a variable is
data_type variable_name = value
Rules of declaring variable
- All variable must be declared before its use in the program.
- All declaration of the same data type can be separated by comma (,) and the declaration is terminated by semi colon (;)
int a,b,c;
float x;
char z;
Share if you liked this Post using your favorite sharing service:
Subscribe Updates, Its FREE!
0 comments:
Post a Comment