C KEYWORDS – A BRIEF DESCRIPTION

C KEYWORDS - The 32 keywords in C Language

30. VOID KEYWORD

The keyword void is one of the C keywords which we can use when the compiler returns no value. Generally, we use the keyword void with function returning no value.

Furthermore, we may use void as a type specifier when defining a function not returning anything.

Generally, the presence of keyword void is not mandatory. Then also, it is good for programming practice to make use of this feature.

SYNTAX :

Keyword_name function_name(arguments)

Here, keyword_name is void. The function_name is any user-defined function. Finally, the arguments are the different variables of different data types.

EXAMPLE :

void fun( )

{

 printf(“HELLO WORLD”);

}

Here, the keyword void represents that the function doesn’t return anything. The output of the above program is,

HELLO WORLD

31. VOLATILE KEYWORD

volatile is one of the C keywords which tells the compiler that the value of the variable may change anytime. That means the value of the variable may change anytime in the program without action of any code.

Generally, whenever the compiler encounters variable, it reads the value of that variable from the memory. But sometimes for optimisation purposes, the compiler stores the value of the current variable in register not-in-use. Now, when the compiler encounters that variable next time and observes no change in variable’s value. Then it reads the value from the register instead of memory.

Overall, the process saves time but this sort of automatic optimisation may sometimes lead to incorrect results. Thus, for the solution we can use volatile qualifier

If user declares a variable with qualifier volatile, then the user is instructing the compiler to turn off optimisation process. And specifically, for that variable only.

SYNTAX :

Keyword_name data_type variable_name;

Here, keyword_name is volatile. The data_type and the Variable_name depends upon user’s choice.

EXAMPLE :

volatile int num;

Generally, if the user don’t want to change the value of volatile variable in program, then we apply qualifier const. For example,

const volatile int num;

 

32. WHILE KEYWORD

while is one of the C keywords which we use when we want to execute block of statements several times. Likewise if-else statement, here we can have either a single or block of statements i.e. known as body of loop.

First of all, the the compiler evaluates the condition. If it is true, then the compiler executes the statements in body of loop. After execution, the compiler again checks the condition and if true then the same execution procedure. When the condition becomes false, the loop terminates and control comes out of the loop. Each execution of loop body is an iteration.

The flowchart for while loop is given below,

While flowchart - C KEYWORDS
https://www.programiz.com

SYNTAX :

keyword_name(condition)

{

  statement;

}

Here, keyword_name is while. The condition may be any expression, and the condition will be true at non-zero value.

EXAMPLE :

int i=1;

while(i<10)

{

  printf(“HI “);

}

Thus, the output of the given example will be

HI HI HI HI HI HI HI HI HI

Thus, it was all about C KEYWORDS – A BRIEF DESCRIPTION…

For any other information about THE C ELEMENTS.. Click on the link below,

THE C ELEMENTS

Leave a comment

Your email address will not be published. Required fields are marked *

15 thoughts on “C KEYWORDS – A BRIEF DESCRIPTION”