KEYWORDS USED IN C LANGUAGE

1. AUTO; this keyword is used to declare automatic variables. And when any variables is declared within a function body, is it automatic by default, therefore there would be no need of the keyword auto on variables within function body.

Auto int var1; this is how a variable is declared automatic

2. BREAK AND CONTINUE;

The break statement terminates the loop immediately when the required condition has been met.

The continue statement skips the statements after it, inside the loop for iteration

for (x=1;x<=10;++x){

if (x==3)

continue;

if (x==7)

break;

printf(“%d “,x);

}

Output

1 2 4 5 6

When x = 3, the continue statement comes into effect and skips 3. When x= 7, the break statement comes into effect and terminates the for loop.

3. SWITCH, CASE, AND DEFAULT

Switch and case statements are used to execute a block of statements from multiple blocks.

switch()

{

case ‘1’:

printf(some statements to execute when 1);

break;

case ‘5’:

printf(some statements to execute when 5);

break;

default:

printf(some statements to execute when default);

}

4. CHAR;

This is used to declare a character variables like ‘A’, ‘B’. And each variable stores a single character.

e.g. char name=’A’; where “name” is the variable name.

5. CONST.

An identifier can be declared constant by using the const keyword.

e.g.

const int a = 5;

6. Do…while

These are used when carrying out a loop

e.g.

int x;

do

{

printf(“%d “,x);

x++;

}

while (x<10)

7. DOUBLE AND FLOAT

These are used to declare floating types of variables

e.g.

float number;

float longnumber;

8. IF AND ELSE

These are used to make decisions

e.g.

if (i == 1)

printf(“i is 1.”)

else

printf(“i is not 1.”)

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

i is not 1

9. ENUM

enum

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

enum suit

{hearts; spades; clubs; diamonds; };

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

10. EXTERN

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

11. FOR

This is used as a loop known as for loop.

e.g.

for (i=0; i< 9;++i){

printf(“%d “,i);

}

12. GOTO

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

for(i=1; i<5; ++i)

{

if (i==10)

goto dust;

}

printf(“i is not 10”);

error:

printf(“dust, count cannot be 10.”);

Output

dust, count cannot be 10.

13. INT

This is used to declare integer type variable.

e.g.

int number;

14. LONG, SHORT, 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;

15. RETURN

This keyword terminates the function and returns the value.

16. SIZEOF

This evaluates the size of data (a variable or constant)

e.g.

#include <stdio.h>

int main()

{

printf(“%u bytes.”, sizeof(char));

}

Output 1 bytes.

17. REGISTER

This creates register variables that are faster than the normal variables

e.g.

register int var1;

18. STATIC

This creates a static variable, and the value of such variable doesn’t change till the end of the program.

e.g.

static int var;

19. STRUCT

This is used for declaring a structure that can hold different type of variables under the same name

struct student{

char name[80];

float marks;

int age;

}s1, s2;

20. TYPEDEF

This is used to explicitly associate a type with an identifier.

typedef float kg;

kg bear, tiger;

21. UNION

This is used to group different types of variables under a single name.

union class {

char name[80];

int marks;

int age;

}

22. VOID

Void simply means that no value, and when used as a function it does not return any value

23. VOLATILE

This is used for creating volatile objects e.g. volatile number.