Table of Contents
C language contains about 31 keywords. Keywords are already defined by compiler for reserve purpose. C language keywords are also called reserve words. Keywords can not be used as variable name
1. auto – The auto keyword is used to declare a type of variable in the C Programming language. It is the automatic variable and it is always a local variable only. This variable is declared either inside block or main.
Syntex
auto int var;
Example
auto int a=10;
Program
Output
The value within block: 5
the value within main: 10
The auto variable cannot be a global variable.
Default value of auto varIable is garbage value.
2. break – the break statement is mostly used in for loop and while loop.
,Do while loop and switch statements
Syntex
break; Program
Output
value of num is : 0
value of num is : 1
value of num is : 2
value of num is : 3
value of num is : 4
exit from while loop
3. continue – the break statement is mostly used in for loop,while loop do while and switch -case statements.
Syntex continue; Example
Output
1
2
3
4
6
7
8
9
10
4. switch and case – swith and case statements are used to execute a block code among multiple statements. likes if … else… if statements
Syntex
switch(expression) { case '1'; //some codes to execute when 1 break; case '2'; //some codes to execute when 2 break; .................... .................... case 'n'; //some codes to execute when n break; }
6. default – default is used to switch -case statements
Syntex default;
7. char – The char keyword declares a character variable. – variable declaration
Syntex
char char_name='value';
Example
char alphabet='A';
8. const – cons is a keyword that assigns an initial value to the variable that cannot be changed by the programmer. – variable declaration.
Syntex
const variable_name=value;
Example
const my_age=22;
9. do – Do is a keyword in c which is commonly used with do- while loop. It looks like other programming languages.
Syntex
do-while(expression)
Example
10. while – while is a keyword in C language which is used to execute a loop statement. While statement executes repeatedly until statement becomes false
Syntex
while(expression)
11. double – double is a keyword in C language which is used to represents floating point value.
Syntex
double value; - variable declaration
Example
double salary=23123.56;
12.float -float is a keyword in C language which is used to represents single precision floating point data type. – variable declaration.
Syntex
float value;
Example
float average=67.7;
13. if – if is a keyword in C language which is used for conditional statements execution. If evaluates expression and when it becomes true(nonzero), statement is executed. Otherwise, when evaluation becomes false(zero), statement of if is skipped.
The basic form syntex of if
Syntex
if(checkExpression) statement1
14. else – If statements may be used together with else. When if statement becomes false(zero), else execute the statement.
Syntex
if(checkExpression) statement1 else statement2
Example
enum variable_name { constant 1, constant 2, constant 3, }
enum Week{
Sunday
Monday
Tuesday
wednesday
Thursday
Friday
Saturday }
16. extern – extern keyword is used for declaring external variables in C. This modifier is used with all data types like int , float, double, array, pointer, structure, function
Syntex
extern data_declaration;
Example
extern int a;
17. for – For is a keyword which is used to repeat looping statements in C Language.
Syntex
for(initialization, Boolean Expresion, increment or dicrement){ // statement(s) }
Example
output
0 1 2 3 4 5 6 7 8 9
18. goto –
goto is a keyword that is used to jumb directly to labled statement when a problem is encountered.
Syntax
goto label_name; statement(s); ................... label_name: statements(s)
Example
20. short – Short is a key word that is a data type in C. We can use short in following types.
short int ;
un signed short int;
signed short int;
21. long – long is a key word that is a data type in C. We can use long in following types.
long long int ;
un signed long int;
signed slong int;
22. signed and unsigned – Signed keyword is used to store negative or positive values
Syntex.
signed data_diclaration;
unsigned data_diclaration;
23. return – return is a keyword that is used to return the value and terminate the function
int function_name()
{
int x=10;
return x;
}
Output
1
4
4
8
25. register – register keyword is used to define local variables.
Syntex
register data_declaration;
Example
register int age;
26. static – static keyword used for variable declaration and method declaration
Syntex
static data_diclaration;
static function_diclaration;
27. struct – struct is a keyword that is used to create a structure. Structure is a user-defined data type used to store a group of variable in a single record.
The syntax of struct
struct [struct_name]
{
[type1_variable_name];
[type2_variable_name];
………………………………
}
Example
29. union – union means one or more variable used declare a single unit like struct (Structure in C) . Except it allows you to define variables that share storage space.
Syntex of union keyword union [union_type_name] { data_type diclaration; }
Example
union student
{
int age;
char name[];
}
30. void – void is a keyword in C Language which is used as a function to return type. Void means that the function can never return a value.
Syntex of void keyword
void function_name(parameter_list) { //statement(s) }
Example for void
void hello(char *name)
{
printf (“hello, %s”,name);
}
Syntex
syntex of the volatile key word
volatile data_type;
Subtract two numbers using method overriding Program 1
PHP Star triangle Pattern program Here's a simple Java program that demonstrates how to print…
Using Function or Method to Write to temperature conversion: Fahrenheit into Celsius In this article,…
Function or method of temperature conversion from Fahrenheit into Celsius In this article, we will…
Write temperature conversion program: from Fahrenheit to Celsius In this article, we will discuss the…
How to write a program to convert Fahrenheit into Celsius In this article, we will…
This website uses cookies.