Identifiers in c language

Identifiers are user-defined names used to identify variables, functions, arrays, structures, and other entities in a C program. Identifiers are an essential part of any programming language, including C, and must follow specific rules to be valid.

Here are some of the rules for creating identifiers in C:

  1. The first character of an identifier must be a letter (a to z or A to Z) or an underscore (_).
  2. The remaining characters can be letters, digits (0 to 9), or underscores.
  3. Identifiers are case-sensitive, meaning that upper- and lowercase letters are treated differently.
  4. Identifiers cannot be keywords or reserved words in the C language.
  5. Identifiers should be meaningful and descriptive, making it easier to understand the purpose of the variable, function, or other entity it represents.

Here are some examples of valid and invalid identifiers in C:

Valid Identifiers:


Invalid Identifiers:

1st_number  (starts with a digit)
if  (keyword)
my-variable  (contains a dash)
#hash  (contains a special character)

In conclusion, identifiers are essential elements in C programming, used to identify various entities in the program. It is essential to follow the rules for creating valid identifiers, as improper use of identifiers can lead to syntax errors and other problems in the program.