Identifiers in c
C identifiers are names given to variables, functions, arrays, structures, unions, and labels in C programming language. They are used to identify and access these entities in the program.
Rules for constructing C identifier
1. Identifiers can contain letters (both uppercase and lowercase), digits, and underscores.Example :
Example :
Types of identifiers
a. Internal identifier
b. External identifier
Internal Identifier
If the identifier is not used in the external linkage, then it is known as an internal identifier. The internal identifiers can be local variables.
External Identifier
If the identifier is used in the external linkage, then it is known as an external identifier. The external identifiers can be function names, global variables.
Differences between Keyword and Identifier
Keyword | Identifier |
---|---|
Keyword is a pre-defined word. | The identifier is a user-defined word |
It must be written in a lowercase letter. | It can be written in both lowercase and uppercase letters. |
Its meaning is pre-defined in the c compiler. | Its meaning is not defined in the c compiler. |
It is a combination of alphabetical characters. | It is a combination of alphanumeric characters. |
It does not contain the underscore character. | It can contain the underscore character. |
Example.
Output
Value of a is : 10
Value of A is :20
The above output shows that the values of both the variables, 'a' and 'A' are different. Therefore, we conclude that the identifiers are case sensitive.
In summary, C identifiers are important names used to identify and access various entities in a C program. By following the simple rules for naming identifiers in C, programmers can ensure that their code is well-organized and easy to read and understand.
0 Comments