Keywords & Identifiers in C Language

In this article, we will learn about the keywords and identifiers in the c language. In simple words, Keywords are special specific words whose meaning is already known to the compiler Identifiers are used for the naming of variables, functions, and arrays. It generally uses for specifies the name of a particular variable.

What are Keywords in C

These words have special meanings and we cannot use these words elsewhere in the program This word is used in a specific condition and it specifies the type of some particular variable? No special symbol can be used keywords have standard predefined meanings. Keywords are also known as reserved words and we cannot alter the meaning of keywords. Keywords are the basic building blocks for developing C programs.

All Keywords in C

There are only 32 keywords in standard C and these keywords must be written in lowercase.
All keywords in c are following

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


These are user-defined names used for naming of variables, function and arrays
We cannot use keyword as identifiers. Identifiers must be different from the keywords because we have studied earlier that keywords are reserved words
That have predefined meanings. Identifiers are simple text or strings to identify various identities. An identifier can consist of alphabetical digits characters and underscores. The first character can be an uppercase, lowercase letter, or underscore.

Rules for Naming Identifiers in C

  • Identifier should not be a keyword
  • Identifiers can not start with a digit.
  • All the identifiers should have a unique name in the same scope
  • The first character of an identifier should always start with an alphabet or underscore, and then it can be followed by any of the characters, digit, or underscore.
  • The special characters such as ‘*’,’#’,’@’,’$’ are not allowed within an identifier.
  • All the identifiers are case sensitive means the identifiers "hello" and "Hello" will be treated differently. However, both names are identical, but one has a lowercase alphabet, and the other has an uppercase alphabet.
  • Length of an identifier should not exceed 31 characters.
  • Any blank spaces or commas are not allowed within an identifier.

Types of Identifiers in C

There are two types of identifiers in C language

1. Internal Identifier
These are also known as internal names which includes the names of local variables. Internal
Identifier can be a local variable that has 31 significant characters.

2. External Identifier
These identifiers are used in the external link process (process refers to a whole program that combines all the translation units(implemented file + all header files ). External identifiers are also known as external names .it can be a name of a function or a global variable. it has at least 63 significant characters.

Difference between Keywords and Identifiers

                Keyword                       Identifiers
These are special specific, reserved words that have special meanings and we cannot use these words elsewhere in the program Identifiers are simple text or strings to identify various identities. An identifier can consist of alphabetical digits characters and underscores.
The keyword specifies the variable type Identifier specifies the name of the variable
No special symbol can be used because these are not user-defined. A special symbol Underscore can be used 
Keyword in c always consists of lowercase  alphabets and starts with lower case Identifier can be both uppercase and lowercase, and it can start with the alphabet or underscore.
Example-:for, float, int, while, do, class, etc. Example -: Vikas, name,school_no, etc.

Code Implementation

#include <stdio.h>

// creating a function 
int add_one(int number) {
  return  number+1;

int main() {

  // creating some data variables 
  char Ch = 'c';
  int  a;
  double double_number = 3.14;
  int z = add_one(5);

  int arr[5]; // array of size five
  return 0;


Identifier- {Ch,double_number,z, arr,a}  
Keyword -{int, double, char, return }

In the above C program we first make a function with the name add_one, here add_one is an identifier,add_one function takes a number in an argument and then simply add 1 to that number. So here add_one is (text with the special character) or a name of the function and this function has return type int. Here it is a keyword that cannot be changed if the return type of the function is integer type you have to use only int. In the main function, we have created three different types of variables with identifiers Ch, a,double_number, and z. In the end, we have created an array with the identifier arr.

Valid Identifiers

  • Size It contains only lowercase alphabets.
  • Name_school It contains only ‘_’ as a special character.
  • Roll1 Here, the numeric digit comes at the end.
  • roll_2 It starts with lowercase and ends with a digit.
  • _size Contains lowercase alphabets and an underscore and It starts with an underscore ‘_’

Invalid Identifiers

  • Float it is a keyword
  • 1name It begins with digit
  • \$god It starts with special character
  • x y it contains a blank space
  • x/y it contains special character

A keyword is a word that has a specific meaning in a programming language and is reserved for a specific use. For example, "if" and "else" are keywords in many programming languages and are used to create conditional statements.

An identifier is a name given to a variable, function, or other objects in a program. Identifiers can be chosen by the programmer, but they must follow the naming conventions of the programming language they are using. For example, in Python, identifiers cannot begin with a number and must contain only letters, numbers, and underscores.

Leave a Reply

Your email address will not be published. Required fields are marked *