Skip to content
Menu
Code for Java c
  • Home
  • Java
    • Java Examples
    • Java tutorials
  • C
    • C tutorials
    • C Examples
  • C++
    • C++ Tutorials
    • C++ Examples
  • Python
    • Python Tutorials
    • Python Examples
  • About
    • About me
    • contact us
    • disclaimer
    • Privacy Policy
Code for Java c

Keywords in C programming Language

Posted on November 21, 2017September 17, 2019

Table of Contents

  • Keywords in C programming Language
    • Explanation of keywords

Keywords in C programming Language

In this tutorial , we will discuss keywords in C language

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


Explanation of keywords

 

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

 

Output
1234

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)

 

Example

Output
1
2
3
4

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

15.enum –  Enumeration (enum)  is a keyword in C Language, which is used to declare user defined data type that consists of numerical value
Syntex

enum variable_name
{
constant 1,
constant 2,
constant 3,
}
Example

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











19. int – int is a keyword in C and it is a data type. int keyword can be signed (Default) or Unsigned types. Default keywords have a range of -32768 to 32767 whole numbers
int a,b,c;
int marks=78;

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;

Example
signed short int a=32000;
unsigned short int a=32000;

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;
}

24.sizeof –The size of is a keyword that evaluates the size of data types

Example

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

28. typedef –   Typedef is a keyword that is used to give a new symbolic name for the existing name a C Program.

Syntex

typedef struct sturct_name
{
ststement(s)
}Exampletypedef struct student
{
int age;
char name[10];
float avg;
}

 

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);
}

31. volatile – volatile is a qualifier that is applied to a variable when it is declared. It means the value of the compiler  variable may changed at any time without any action being taken by the code.

Syntex

syntex of the volatile key word

volatile data_type;

Related

Recent Posts

  • Subtract two numbers using method overriding
  • PHP Star triangle Pattern program
  • Using function or method to Write temperature conversion : Fahrenheit into Celsius
  • Function or method:temperature conversion from Fahrenheit into Celsius – Entered by user
  • Write temperature conversion program: Fahrenheit into Celsius
  • How to write a program to convert Fahrenheit into Celsius

tag

Addition (6) Array (38) C++ language (91) C language (98) c sharp (23) Division (6) Function (29) if else (32) Java language (102) JavaScript (5) loops (137) Multiply (7) Oop (2) patterns (65) PHP (13) Python Language (38) Subtraction (7) temperature (20)

Archives

Categories

Address

Global information technology

Puloly south, PointPedro

Jaffna

Srilanka

©2025 Code for Java c | Powered by SuperbThemes