Keywords and identifiers in C

In this tutorial, you will learn character set in C, C tokens, C keywords and identifiers in C.

Character Set

The set of alphabets, digits and special characters that are valid in the C language is called the character set.

Alphabets

Both lowercase(a – z) and uppercase(A – Z) alphabets are accepted by C.

Digits

C accepts all digits from 0 to 9.

Special Characters

C supports the usage of the following special characters.

,$]&^|
<(:#{!
>)%?}*\
.;[/~
+

White spaces

Blank spaces, horizontal tab, carriage return, newline and form feed characters are allowed in C. White spaces may be used to separate words, but they are not permitted between keywords and identifiers.

C tokens

The smallest individual units in a C program is known as C tokens. C has six types of tokens as shown in the figure.

c tokens

Keywords

Predefined reserved words with fixed meanings are called keywords. Since keywords are the building blocks for program statements, they cannot be used as identifiers. Since C is case sensitive, all keywords must be written in lowercase. The list of all keywords available in C is given below:

  • auto
  • break
  • case
  • char
  • const
  • continue
  • default
  • do
  • double
  • else
  • enum
  • extern
  • for
  • float
  • if
  • goto
  • int
  • long
  • register
  • return
  • short
  • static
  • sizeof
  • signed
  • struct
  • switch
  • typedef
  • union
  • void
  • unsigned
  • volatile
  • while

Identifiers

The names of variables, functions, and arrays are referred to as identifiers. These are user-defined names consisting of a sequence of letters and digits. Identifiers must be unique.

The rules for naming identifiers in C

  • Must consist of only letters, digits or underscore.
  • Both uppercase and lowercase letters are permitted.
  • The first character must be a letter of the alphabet or underscore.
  • Only first 31 characters are significant.
  • Cannot use a keyword.
  • Must not contain white space.

For example:

int age;
float mark;

Here age and mark are identifiers.

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments