Basics of C Programming

⯈Basic C Programs

Identifiers in C

Identifier is a name given to a variable, function or an array. We will discuss each one these in the coming chapters in detail.

Identifier is a combination of letter’s, digits and underscore.

There are some rules for making an identifier in C, they are

  1. Identifier name should begin with a letter or underscore (_).
  2. Keywords cannot be used as an identifier name, since they are reserved.
  3. There should not be any white space characters like space, newline or tab.
  4. There should not be any special symbol in an identifier name. The only special symbol allowed is underscore (_).

Some valid identifiers

  1. number_of_students
  2. temperatureCelsius
  3. _
  4. a1
  5. __ (two underscore’s continuously)
  6. a
  7. Int (it is valid identifier, int is keyword. but not Int, keywords are written in lowercase and here ‘I’ is in upper case)
Note: Identifier names are case sensitive. Meaning 'A' is not same as 'a'.
The following identifier names are different even though the names are same:
  1. temp and Temp
  2. a and A
  3. number and numbeR
Note: Even if there is a single character mismatch, the identifier names will be different.

Some invalid identifiers

  1. 1a (starts with digit, should start with letter or underscore)
  2. number of students (contains white spaces)
  3. $ub (contains special symbol)
  4. int (is a keyword)
Scroll to Top