Loading...
C List of all keywords in C Language

List of all keywords in C Language

In this tutorial, we will learn about all of the 32 keywords in C programming..

Keywords in C Language
auto break case char const
continue default do double else
enum extern float for goto
if int long register return
short signed sizeof static struct
switch typedef union unsigned void
volatile while

Description of all Keywords in C


auto

The auto keyword is used to declare automatic variables.

Example :

auto int grade;

In the above example, grade is a variable of storage class auto and type int.

They are recreated each time a function is executed and also known as local variables.

Visit auto keyword to learn more.


break and continue

The break statement is a loop control statement which is used to terminate the loop and switch statement immediately.

Syntax :

break;

The continue statement is a loop control statment used to skips the current iteration of the loop and continues with the next iteration of the loop.

Syntax :

continue;

Visit Break and continue to learn nore.


switch, case and default

The switch statement is used to execute different parts of code based on the value of expression.

Syntax :

switch (expression)
​{
  case constant1:
  // statements
  break;
  case constant2:
  // statements
  break;
  .
  .
  default:
  // default statements
}

Visit C switch statement to learn more.


char

The char keyword is used to declares a character variable.

Char datatype is used to store a single character within a single quotation.

We have to use char keyword to declare a character datatype.

char datatype use 1 byte memory to store a single character.

Syntax :

char variable_name;

Visit C data types to learn more.


const

Contants are those variables whose value cannot be changed.

To declare a constant we have to use the const keyword.

const type variableName value;

Visit, C variables and constants to learn more.


do...while

The do-while loop is exit-controlled loop.

In do-while loop the loop body will execute at least once irrespective of test condition.

Syntax :

do {
// body of loop;
}
while (condition);

Visit C do...while loop to learn more.


double and float

Float datatype is used to store decimal numbers with single precision. Double datatype is used to store double precision.

We have to use float keyword to declare a float type variable and double keyword to declare a double type variable.

Syntax :

float grade;
double percentage;

Here, grade is a single-precision floating type variable whereas, precentage is a double-precision floating type variable.

Visit C data types to learn more.


if and else

The if statement allows us to control if a program enters a section of code or not based on whether a given condition is true or false.

Syntax :

if (condition) {
  //statements to be executed of the given condition is True
}
else {
  // statements to be executed if the given condition is False
}

Visit C if...else statement to learn more.


enum

In C programming, an enumeration is a special class that represents a group of constants.

The enum keyword is used to create enumeration classes.

Syntax :

enum flag {
  const1,const2, ..., constN
};

By default, const1 or the first item in the list is assigned with the value 0, const2 or the second item in the list is assigned with the value is 1 and so on.
We can change default values of enum elements according to our requirement during declaration.

Visit C enum to learn more.


extern

The extern keyword is used to define extern storage class.
These variables or functions are shared between two or more files.

Syntax :

extern dataType varible_name;

Visit C storage type to learn more.


for

The for loop is used for executing a block of statements repeatedly until a specified condition is satisfied.

syntax :

for (initialization ; condition ; increment/decrement)
{
   // statements for repeated execution
}

Visit C for loop to learn more.


goto

The goto statement is a jump control statement that allows us to transfer control of the other part of the program with the help of a label.

Syntax :

goto label;
..........
..........
label:
statement;
..........

Visit C goto to learn more.


int

Int datatype is used to store an integer.

We have to use int keyword for declaring an integers (whole number both postive and negative including 0) before variable name.

Syntax :

int variableName;

Visit C data types to learn more.


short, long, signed and unsigned

The short, long, signed and unsigned keywords are type modifiers use to change the base meaning of the datatype to create new datatype.

Syntax :

short int a;  //small integer
long int b; //large integer
signed int c; //normal integer
unsigned int d; //positive integer

Range of datatypes :

Type Size (bytes) Format Specifier Range
short int 2 %hd -32,768 to 32,767
long int 4 %d, %i -2,147,483,648 to 2,147,483,647
unsigned int 2 or 4 %u 0 to 65,535
signed int 4 %d -32,768 to 32,767 or -2,147,483,648 to 2,147,483,647

Visit C data types to learn more.


return

The Return statement is used to terminate teh execution of a function and transfer program control back to the calling function.

It can also specify a value to be returned by the function.

Syntax :

void Number() {
  // statement
}

Visit C Functions to learn more.


register

register keyword is used to define Register variable.

The register storage class is used to define local variables and the size of register storage class has a maximum size equal to the register size .

Syntax :

register int varible_name;

Visit C Storage Classes to learn more.


sizeof

The sizeof operator is the unary operator in C used to compute the size of its operand i.e. it return the size of a variable.

Example :

#include <stdio.h>

int main() {
int a;
float b;
double c;
char d;
printf("Size of int=%lu bytes\n", sizeof(a));
printf("Size of float=%lu bytes\n", sizeof(b));
printf("Size of double=%lu bytes\n", sizeof(c));
printf("Size of char=%lu byte\n",sizeof(d));
return 0;
}

Output

Size of int = 4 bytes
Size of float = 4 bytes
Size of double = 8 bytes
Size of char = 1 byte

Visit C operators to learn more.


static

The variable defined using static storage class is called Static variable.
They can be assigned only once and exist till the termination of the program.

Syntax :

static int varible_name;

Visit C Storage Classes to learn more.


struct

A struct (or structure) is a group or collection of variables (can be of different types) represented by a single name.

We use struct keyword to create a structure in C programming.

Syntax

struct structureName {
  dataType member1;
  dataType member2;
  dataType member3;
  ...
  ...
  ...
};

Visit C Structure to learn more.


typedef

typedef is used to create an alias name for datatypes i.e. an alias of struct . It helps us to make the code short and improve the readability.

Example :

typedef struct studentData {
  int feet;
float inch;
} student;
...
...
...
...
student student1;
student1.name = "Tony";

Visit Structure to learn more.


union

A union is a user-defined data type used to store different type data types which are grouped together.

Syntax

union unionName {
  dataType member1;
  dataType member2;
  dataType member3;
  ...
  ...
  ...
};

Visit C Union to learn more.


void

Void means "nothing" or "no-type" i.e. It is an empty datatype that has no value and can be used in functions and pointers.
We can assume void as absent.

Note : void is mainly used to represent the function when it is not returning anything.


volatile

Volatile keyword is a qualifier which is applied to a variable when it is declared. It is used to tells the compiler that the value of the variable may change at any time.

volatile int a;

Here, a is a volatile variable.

- Related Topics