Keywords in C

Keywords in C. Keywords in C Tutorial. Learn Keywords in C
Keywords in C

What is Keywords in C?

Keywords in C are predefined reserved words that have a specific meaning in the C programming language. These words cannot be used as variable names, function names, or any other identifiers. They are used to define the syntax and structure of the C language and play a crucial role in its compilation and interpretation.

Keywords are used to define various elements of the C language, such as data types, control structures, loops, functions, and storage classes. They provide a standard set of instructions that the compiler can interpret and execute efficiently.

There are a total of 32 keywords in C, and they can be divided into the following categories:

  1. Data types: These keywords are used to define the basic data types in C, such as int, char, float, double, and void.
  2. Control structures: These keywords are used to control the flow of the program, such as if, else, switch, case, and default.
  3. Loops: These keywords are used to implement iteration, such as for, while, and do.
  4. Functions: These keywords are used to define functions, such as return, break, and continue.
  5. Storage classes: These keywords are used to define the storage class of variables, such as auto, register, static, and extern.

Types of Keywords in C:

SR. NO.KeywordInformation
1autoUsed to declare local variables with automatic storage duration.
2breakUsed to exit from a loop or switch statement.
3caseUsed to define a case in a switch statement.
4charUsed to define a character data type.
5constUsed to define a constant value.
6continueUsed to skip the current iteration of a loop.
7defaultUsed to define a default case in a switch statement.
8doUsed to define a do-while loop.
9doubleUsed to define a double-precision floating-point data type.
10elseUsed to define an alternative branch in an if statement.
11enumUsed to define an enumerated data type.
12externUsed to declare a variable or function that is defined in another file.
13floatUsed to define a single-precision floating-point data type.
14forUsed to define a for loop.
15gotoUsed to jump to a labeled statement.
16ifUsed to define a conditional statement.
17intUsed to define an integer data type.
18longUsed to define a long integer data type.
19registerUsed to declare local variables with register storage duration.
20returnUsed to return a value from a function.
21shortUsed to define a short integer data type.
22signedUsed to define a signed data type.
23sizeofUsed to determine the size of a data type or variable.
24staticUsed to declare a variable or function with static storage duration.
25structUsed to define a structure data type.
26switchUsed to define a switch statement.
27typedefUsed to define a new data type.
28unionUsed to define a union data type.
29unsignedUsed to define an unsigned data type.
30voidUsed to define a void data type.
31volatileUsed to declare a variable that can be modified by hardware or other software.
32whileUsed to define a while loop.

Rules while declaring Keywords in C:

  1. Keywords cannot be used as variable names, function names, or any other identifiers.
  2. Keywords are case sensitive and must be spelled correctly.
  3. Keywords cannot be abbreviated or modified in any way.

More: