Rules for Constructing C Identifiers
-
The first character of the identifier should be a letter or an underscore, followed by any combination of characters, digits, or underscores. -
Identifiers cannot start with a digit. -
Identifiers are case-sensitive, so we can say that identifiers are case-sensitive. -
Identifiers cannot contain commas or spaces. -
Keywords cannot be used as identifiers. -
The length of an identifier should not exceed 31 characters. -
Identifiers should be written in a meaningful, concise, and easy-to-read manner.
Examples of Valid Identifiers
total, sum, average, m, sum_1, etc.
Examples of Invalid Identifiers
2sum (starts with a numerical digit) int (reserved word) char (reserved word) m+n (special character, i.e., '+')
Types of Identifiers
-
Internal Identifier -
External Identifier
π Click to Claimπ
Internal Identifier
External Identifier
The Difference Between Keywords and Identifiers is as Follows
Letβs Understand Through an Example
int main() { int a=10; int A=20; printf("The value of a is: %d",a); printf("\nThe value of A is: %d",A); return 0; }
Output
The value of a is: 10The value of A is: 20
The above output shows that the values of variable ‘a’ and ‘A’ are different. Therefore, we can conclude that identifiers are case-sensitive.
Programmer Technical Exchange Group
Please remember to note: City, Nickname, and Technical Direction when scanning to join the group.