Keywords in C: C Keywords are reserved words that have predefined meanings and cannot be used as identifiers like variable names or function names. Keyword is a most important part of programming languages like C, C++, Java and Python etc.
Reserve 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 |
Auto Keyword: A Automatic keywords are used to storage class. It is a default variable name.
Example of Auto Keyword in C
| #include<stdio.h> #include<conio.h> void main(){ clrscr(); auto x=10; printf("Value of x:%d",x); getch(); } ============OUTPUT============ Value of x:10 |
Break Keyword: A break Keyword can be used terminate the loops. If given condition are true.
Example of Break Keyword in C
| #include<stdio.h> #include<conio.h> void main(){ clrscr(); for(int i=1;i<=10;i++){ if(i==5) break; printf("%d\n",i); getch(); } ============OUTPUT============ 1 2 3 4 |
Case Keyword: A case Keyword can be used with switch statement. It is a case uses of same condition statement.
Example of Case Keyword in C
| #include<stdio.h> #include<conio.h> void main(){ clrscr(); int n=2; switch(2){ case 1: printf("case one executed"); break; case 2: printf("case two executed"); break; case 3: printf("case three executed"); break; default: printf("case are not match"); } getch(); } ============OUTPUT============ case two executed |
Char Keyword: A character Keyword can be used only single character Value.
Example of Char Keyword in C
| #include<stdio.h> #include<conio.h> void main(){ clrscr(); char c='J'; printf("Character Keyword:%c",c); getch(); } ============OUTPUT============ Character Keyword: J |
Const Keyword: A Const Keyword can be used value can not be changed. It is a constant value like integer, floating and character value.
Example of Const Keyword in C
| #include<stdio.h> #include<conio.h> void main(){ clrscr(); const int x=200; const float y=88.5; const char c='J'; printf("Integer Constant:%d\n",x); printf("Float Constant:%f\n",y); printf("Character Constant:%c",c); getch(); } ============OUTPUT============ Integer Constant:200 Float Constant:88.5 Character Keyword: J |
Continue Keyword: A Continue Keyword can be used skip the next iteration. Continue keyword can be used with for loop, while loop, do-while loop.
Example of Continue Keyword in C
| #include<stdio.h> #include<conio.h> void main(){ clrscr(); for(int i=1;i<=5;i++){ if(i==3) continue; printf("%d\n",i); getch(); } ============OUTPUT============ 1 2 4 5 |
If Else Keyword: The if-else statement allows you can specify two different actions. If the condition are true than if body will be execute otherwise else body will be execute.
Example of If-Else Keyword in C
| #include<stdio.h> #include<conio.h> void main(){ clrscr(); int age=18 if(age>=18{ printf("You can derive a car"); } else{ printf("You can not derive a car"); } getch(); } ============OUTPUT============ You can derive a car |
Register Keyword: The register keyword can be used to suggest that a local variable be stored the value in CPU.
Example of Register Keyword in C
| #include<stdio.h> #include<conio.h> void main(){ clrscr(); register int x=80; printf("Value of Register x:%d",x); getch(); } ============OUTPUT============ Value of Register x:80 |
Static Keyword: A static keyword can be used to static variable and functions is memory allocated and initialized only one time before the program starts executing and not released until the program terminates.
Example of Static Keyword in C
| #include<stdio.h> #include<conio.h> void main(){ clrscr(); for(int i=1;i<=5;i++){ static int x=0; printf("Static value of x:%d\n",x++); getch(); } ============OUTPUT============ Static value of x:0 Static value of x:1 Static value of x:2 Static value of x:3 Static value of x:4 |
Sizeof Keyword: A sizeof Keyword can be used to find memory size of any data types.
Example of Sizeof Keyword in C
| #include<stdio.h> #include<conio.h> void main(){ clrscr(); int x=100; float y=78.6; char c='J'; double phone=969040; printf("Size of Integer:%d\n",sizeof(x)); printf("Size of Float:%d\n",sizeof(y)); printf("Size of Character:%d\n",sizeof(c)); printf("Size of Double:%d\n",sizeof(phone)); getch(); } ============OUTPUT============ Size of Integer:4 Size of Float:4 Size of Character:1 Size of Double:8 |
Struct Keyword: A struct Keyword can be used collection of different data types. It can be stored multiple data type values like integer, float, character and more variable used in structure keyword.
Example of Struct Keyword in C
| #include<stdio.h> #include<conio.h> struct student{ int id; float marks; }s; void main(){ clrscr(); s.id=101; s.marks=89.8; printf("Student id:%d\n",s.id); printf("Student marks:%f",s.marks); getch(); } ============OUTPUT============ Student id:101 Student marks:89.800003 |
Union Keyword: A union Keyword is a collection of different data type. Union is a user defined data type. Union can be support single shared memory location. Union does not multiple variable stored in memory. It can be stored only single value at a time.
Example of Union Keyword in C
| #include<stdio.h> #include<conio.h> union student{ int id; float marks; }s; void main(){ clrscr(); s.id=101; s.marks=89.8; printf("Student id:%d\n",s.id); printf("Student marks:%f",s.marks); getch(); } ============OUTPUT============ Student id:1119066522 Student marks:89.800003 |
While Keyword: A while loop perform as action that repeats the number of values. if the given condition are true.
Example of While Keyword in C
| #include<stdio.h> #include<conio.h> void main(){ clrscr(); int x=1; while(x<=5){ printf("value of x:%d\n",x); x++ } getch(); } ============OUTPUT============ value of x:1 value of x:2 value of x:3 value of x:4 value of x:5 |
Conclusion of Keyword in C
Conclusion: This is a all about keyword in C language. You can not define variable name in C program because keyword are reserved word in C Language. If any suggestion keyword related you can comment or contact me. I can solve keyword related problems.

0 Comments