Table of contents
1.
Introduction
2.
Keywords 
3.
C Keywords
4.
Identifiers
5.
Types of Identifiers
6.
Rules for defining Identifiers
7.
Differences between Keyword and Identifier
8.
Frequently Asked Questions
9.
Key Takeaways
Last Updated: Mar 27, 2024

Identifiers and Keywords

Author Shivam Verma
0 upvote
Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

Every programming language has Keywords and Identifiers, which are only understood by its compiler. Identifiers and Keywords in the C Language are the building block of any program. An Identifier is user-defined, which means you can specify identifiers while writing the C language program. While Keywords are predefined, which means the C language has a list of keywords. Let us discuss keywords and identifiers in detail.

Also See, Sum of Digits in C, C Static Function

Keywords 

In every programming language, there are certain reserved words that are used internally and have some meaning for the language. These words are called Keywords. Keywords help in defining any statement in the program.

Here are some useful points related to Keywords.

  • We can not use a keyword as an Identifier.
  • Keywords are always written in lowercase.
  • Keywords can only contain alphabetical characters.
  • A keyword is a reserved word whose meaning is already defined in the compiler.
  • Keywords have fixed meanings, and we can not change the meaning of keywords.

Must see, odd or even program in c

C Keywords

There are only 32 keywords in C language, which are given below

auto 

signed

int

unsigned

break

default

float

short

case

enum

double

struct

char

goto

const

switch

do

register

continue

typedef

extern

sizeof

for

volatile

if

void

long

while

else

return

static

union

Also read, Bit stuffing program in c

Identifiers

All the words we use in our programs always be keywords or identifiers. Keywords are predefined words and can not be changed by the user, while Identifiers are user-defined words used to give names to entities like variables, functions, arrays, structures, etc. Identifiers are created to provide a unique name to an entity to identify it during the program's execution. For example

int weight;

float height;

In the above example, int and float are Keywords, and weight and height are Identifiers.

You can also read about C dynamic array and Short int in C Programming

Types of Identifiers

  1. External identifier
  2. Internal identifier

External Identifier

The identifier which is used in the external linkage is known as an external identifier. The external identifiers can be function names, global variables.

Internal Identifier

The identifier which is not used in the external linkage is known as an internal identifier. The internal identifiers can be local variables.

Rules for defining Identifiers

  • The first character of each identifier should be an alphabet or an underscore.
  • A Keyword cannot be represented as an identifier.
  • Identifiers should not begin with any numerical digit.
  • The name should be formed using only letters, numbers, or underscore.
  • Since C language is case-sensitive, the uppercase and lowercase letters are considered different. For example, value, Value, and VALUE are three different identifiers.
  • Identifiers are generally given meaningful names. Some valid identifiers names are Value, net_val, _data, mark, etc. 
  • An identifier name may be arbitrarily long. But ANSI standard compilers recognize 31 characters.
     

You can also read about the jump statement, Tribonacci Series

Differences between Keyword and Identifier

Sr. No.

Keyword 

Identifier 

1 Keywords are predefined words, which means the C language has a list of keywords. Identifiers are user-defined words, which means you can specify identifiers while writing the C language program. 
2 Keywords always start with a lowercase letter. The first character of each identifier should be an alphabet or an underscore.
3 Keywords must be written in a lowercase letter. Identifiers can be written in both lowercase and uppercase letters.
4 Keywords can only contain alphabetical characters. Identifiers can consist of alphabetical characters, digits, and underscores.
5 There is no special symbol or punctuation is used. There is no punctuation or special symbol, except the underscore, is used.
6 Keywords specify the type of entity. Identifiers classify the name of the entity.
7 Examples of keywords are char, for, while, else, int, if, etc. Examples of identifiers are Value, _data, height, mark, etc.

You can practice by yourself with the help of online python compiler.

Frequently Asked Questions

  1. How many keywords are in the C language?
    Ans: There are total 32 keywords in the C language.
     
  2. What are keywords in C language?
    Ans: Keywords are words that have special meaning to the C compiler.
     
  3. What are Identifiers in C language?
    Ans: Identifiers are words or texts used to identify anything in the C language.
     
  4. Which format identifier is used for the int data type.
    Ans: Both %d and %i can be used as a format identifier for the int data type.

Key Takeaways

In this blog, We learned about Keywords, Identifiers, types of Identifiers, and rules for naming Identifiers. We also discussed the difference between a Keyword and an Identifier. This blog is over, but the thirst for learning is not over yet. Use our practice platform Coding Ninjas Studio to practice various DSA questions asked in many interviews. Till then, have a nice day and Happy Coding.

Live masterclass