Identifier refers to name given to different entities such as constants, variables, structures, functions, etc.
Example
int age;
double mobile_number;
Here age
and mobile_number are
identifier. int
and double
are data type.
Rules for naming Identifier
- We cannot use keywords as identifier.
- The first letter of an identifier should be either a letter or an underscore. An identifier can start with the alphabet, and underscore only. It can’t start with a digit.
- No whitespace, commaare allowed within the identifier.
- Identifiers are case sensitive.
- There is no rule on how long an identifier can be. However, you may run into problems in some compilers if the identifier is longer than 31 characters.
** There is a total of 63 alphanumerical characters that represent the identifiers.
Item | Number |
Capital letter (Uppercase) in the English alphabet | 26 |
Small letter (Lowercase) in the English alphabet | 26 |
Underscore | 1 |
Digit (0-9) | 10 |
Total | 63 |
Keyword vs Identifier
Keyword | Identifier |
Keyword is a pre-defined word. | Identifier is a user-defined word |
It is a combination of alphabetical characters. | It is a combination of alphanumeric characters. |
It can only be written in lowercase | It can be written in lowercase and uppercase letters. |