Keywords & Identifiers


In this tutorial, you will learn about keywords and identifiers. Keywords which are reserved words in the C programming language and essential parts of its syntax. Additionally, you will learn about identifiers and the process of naming them. Keywords and identifiers are both integral for defining syntax, semantics, and precise communication in C programming.

Keywords

Keywords in C programming represent reserved words with predefined meanings. These words cannot be utilized as identifiers, such as variable names or function names.
These keywords are part of the languageโ€™s syntax and serve specific purposes in the code. Some examples of keywords in C programming include โ€œif,โ€ โ€œelse,โ€ โ€œfor,โ€ โ€œwhile,โ€ โ€œint,โ€ โ€œfloat,โ€ โ€œreturn,โ€ and โ€œswitch.โ€ These keywords are crucial for defining control structures, data types, and other fundamental aspects of C programming.

For instance:

int money;

Money is a variable of type int, as indicated by the keyword โ€œintโ€ in this sentence (integer).

In C programming, it is important to type all keywords in lowercase because C is a case-sensitive language.


Identifiers

In C programming, Identifier refers to name given to various program elements such as variables, functions, arraysย etc. These names enable the identification and referencing of these program elements within the code.

It is good practice to choose meaningful and descriptive names for identifiers, making the code more readable and understandable.

For instance

int school;
double students;

Here, we can identify โ€œschoolโ€ and โ€œstudentsโ€ as identifiers.

Also, keep in mind that identifier names and keywords must be distinct. Since int is a keyword, you cannot use int as an identifier.

Rules for naming identifiers

  1. They can consist of letters (both uppercase and lowercase), digits, and underscores.

  2. The first character of an identifier must be a letter or an underscore.
  3. They should not be a keyword or a reserved word in C.

  4. Identifiers in C programming treat uppercase and lowercase letters as distinct, which means they are case-sensitive.

Identifiers must be distinct, as they serve the purpose of providing a unique name to an entity that facilitates its identification during the execution of an application.


ย