What are keywords in C

What are Keywords in C?

In C/C++ some words are reserved which have a special meaning. These words are known as keywords. In General, Keywords are those reserved words that have special meaning in C language. The meaning of the C language keyword has already been conveyed to the C compiler. These meanings cannot be changed. Thus, keywords cannot be used as variable names because it will try to change the existing meaning of the keyword, which is not allowed. (Don’t worry if you don’t know what the variables are, you’ll soon understand. )

What are keyword in C?

This tutorial provides a brief overview on all 32 keywords in C programming.

Keywords in C Programming

struct switchtypedefunion

Description of all Keywords in C

auto –

The auto keyword is use to declare automatic variables.
For example:
auto int var5;
This statement indicates that var5 is a variable of storage class auto having type int.
The variables declared within function bodies are by default automatic. They are re-created each time at the function execution.
Since automatic variables are local to a function, they are also known as local variables.

break & continue –

The innermost loop terminates immediately when a break statement is encountered. It is also used to terminate the switch statement.
The continue statement leaves subsequent statements inside the loop for iteration.

for (i=1;i<=10;++i){   
if (i==3)  
if (i==7) 
 printf("%d ",i);

When i is equals to 3, at that time continue statement comes into effect and skips 3. When i becomes equal to 7, the break statement comes into effect and terminates the for loop.

switch, case and default –

The switch & case statement is used when a block of statements has to be executed among many blocks. For example:

case '1':   
 //some statements to execute when condition is 1  
case '5':  
  //some statements to execute when condition is 5  
 //some statements to execute when default;


The char keyword declares a character variable.
For example:
char alphabet;
Here, alphabet is a character type variable.

To learn more, visit C data types.

const –

An identifier can be declared constant by using the const keyword.
const int a = 5;

To learn more, visit C variables and constants.

do while
int i;
do {  
 printf("%d ",i);  
while (i<10)

double and float –

Keywords double & float are use to declare floating type variables.
For example:
float number;
double longNumber;

Here, number is a single-precision floating type variable whereas, longNumber is a double-precision floating type variable.

if and else –

In C programming, if & else are use to make decisions.

if (i == 7)  
printf("i is 7.");
 prinf("i is not 7.");

If the value of i is other than 7, the output will be :
i is not 7

enum –

Enumeration types are declared in C programming using the keyword enum.
For example:

enum suit{  

Here, an enumerated variable suit is created having tags: hearts, clubs, spades, and diamonds.

extern –

The extern keyword declares that a variable or a function has external linkage outside of the file it is declared.

for –

There are three types of loops in C programming. The for loop is written in C programming using the keyword for. For example:

for (i=0; i< 5;++i){ 
 printf("%d ",i);

goto –

The goto statement is use to transfer control of the program to the specified label. For example:

for(i=1; i<5; ++i){   
 if (i==10)    
goto error;
printf("i is not 10");
printf("Error, count can't be 10.");

int –

The int keyword is used to declare integer type variables.
For example:
int count;
Here, count is an integer variable.

short, long, signed and unsigned

The short, long, signed and unsigned keywords are type modifiers that alter the meaning of a base data type to yield a new type.

short int smallInteger;
long int bigInteger;
signed int normalInteger;
unsigned int positiveInteger;

return –

The return keyword terminates the function and returns the value.

int func() {   
int b = 5; 
return b;

This function func() returns 5 to the calling function.

sizeof –

The sizeof keyword evaluates the size of data (a variable or a constant).

#include <stdio.h>
int main()
 printf("%u bytes.",sizeof(char));

register –

The register keyword creates register variables which are much faster than normal variables.
register int var1;

static –

The static keyword creates a static variable. The value of the static variables persists until the end of the program.
For example:
static int var;

struct –

The struct keyword is used for declaring a structure. A structure can hold variables of different types under a single name.

struct student{ 
 char name[80];    
 float marks;   
  int age;
s1, s2;

typedef –

The typedef keyword is use to explicitly associate a type with an identifier.
typedef float kg;
kg bear, tiger;

union –

A union is use to group different types of variables under a single name.

union student { 
 char name[80]; 
 float marks; 
 int age;

void –

The void keyword meaning nothing or no value or empty.

void testFunction(int a) { 

Here, the testFunction() function cannot return a value because its return type is void.

volatile –

The volatile keyword is use to create volatile objects. A volatile object can be modified by the hardware in an unspecified way.
const volatile number
Here, number is a volatile object.
Since number is a constant, the program cannot change it. However, hardware can change it since it is a volatile object also.

Range of int type data types

Data typesRange
short int32768 to 32767
long int2147483648 to 214743648
signed int32768 to 32767
unsigned int0 to 65535

Leave a Comment