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 −
| auto | double | int | struct |
| break | else | long | switch |
| case | enum | register | typedef |
| char | extern | return | union |
| const | short | float | unsigned |
| continue | for | signed | void |
| default | goto | sizeof | volatile |
| do | if | static | while |
Example
Given below is the C program for the Simple Calculator by using the Switch Case −
#include <stdio.h>
int main(){
char Operator;
float num1, num2, result = 0;
printf("\n Try to Enter an Operator (+, -, *, /) : ");
scanf("%c", &Operator);
printf("\n 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("\n entered operator is invalid ");
}
printf("\n 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.