What are the different types of keywords in C language?


Keywords are generally called as pre-defined or reserved words in a programming language. Every keyword in C language performs a specific function in a program.

  • Keywords cannot be used as variable names.

  • Keywords have fixed meanings, and that meaning cannot be changed.

  • They are the building block of a 'C' program.

  • C supports 32 keywords.

  • All the keywords are written in lowercase letters.

The different types of keywords are as follows −

autodoubleintstruct
breakelselongswitch
caseenumregistertypedef
charexternreturnunion
constshortfloatunsigned
continueforsignedvoid
defaultgotosizeofvolatile
doifstaticwhile

Example

Given below is the C program for the Simple Calculator by using the Switch Case

 Live Demo

#include <stdio.h>
int main(){
   char Operator;
   float num1, num2, result = 0;
   printf("
Try to Enter an Operator (+, -, *, /) : ");    scanf("%c", &Operator);    printf("
Enter the Values for two Operands: ");    scanf("%f%f", &num1, &num2);    switch(Operator){       case '+': result = num1 + num2;       break;       case '-': result = num1 - num2;       break;       case '*': result = num1 * num2;       break;       case '/': result = num1 / num2;       break;       default: printf("
entered operator is invalid ");    }    printf("
The result of %.2f %c %.2f = %.2f", num1, Operator, num2, result);    return 0; }

Output

When the above program is executed, it produces the following result −

Enter an Operator (+, -, *, /) : *
Enter the Values for two Operands: 34 12
The result of 34.00 * 12.00 = 408.00

In the above example, the keywords that are used to perform a simple calculator program are as follows −

Int, char, switch, case, break, float, default, return

These words cannot be used as variables while writing the program.

Updated on: 03-Sep-2021

9K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements