Number of Keywords in C++ Language

Number of Keywords in C++ Language
Number of Keywords in C++ Language

Keywords in C++: C++ Keywords are reserved words that have predefined meanings and cannot be used as identifiers like variable names or function names or class name.

Total Reserve Keywords in C++

autobreakcasechar
constcontinuedefaultdo
doubleelseenumextern
floatforgotoif
intlongregisterreturn
shortsignedsizeofstatic
structswitchtypedefunion
unsignedvoidvolatilewhile
class public private protected
virtual override final new
delete this friend using
namespace template operator try
catch throw true false

Auto Keyword: A Automatic keywords are used to storage class. It is a default variable name.

Auto Keyword in C++

#include<iostream>
using namespace std;
int main(){
auto x=10;
cout<<"Value of x:"<<x;
}
============OUTPUT============
Value of x:10

Break Keyword: break Keyword can be used terminate the loops. If given condition are true.

Break Keyword in C++

#include<iostream>
using namespace std;
int main(){
for(int i=1;i<=10;i++){
    if(i==5)
    break;
cout<<i<<endl;
}
============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.

Case Keyword in C++

#include<iostream>
using namespace std;
int main(){
int n=2;
switch(2){
case 1:
         cout<<"case one executed";
             break;
case 2:
         cout<<"case two executed";
             break;
case 3:
         cout<<"case three executed";
              break;
default:
cout<<"case are not match";
}
}
============OUTPUT============
case two executed
Char Keyword: character Keyword can be used only single character Value.

Char Keyword in C++

#include<iostream>
using namespace std;
int main(){
char c='J';
cout<<"Character Keyword:"<<c;
}
============OUTPUT============
Character Keyword: J
Const Keyword: Const Keyword can be used value can not be changed. It is a constant value like integer, floating and character value.

Constant Keyword in C++

#include<iostream>
using namespace std;
int main(){
const int x=200;
const float y=88.5;
const char c='J';
cout<<"Integer Constant:"<<x<<endl;
cout<<"Float Constant:"<<y<<endl;
cout<<"Character Constant:"<<c;
}
============OUTPUT============
Integer Constant:200
Float Constant:88.5
Character Keyword: J
Continue Keyword: Continue Keyword can be used  skip the next iteration. Continue keyword can be used with for loop, while loop, do-while loop.

Continue Keyword in C++

#include<iostream>
using namespace std;
int main(){
for(int i=1;i<=5;i++){
    if(i==3)
    continue;
cout<<i<<endl";

}
============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.

If-Else Keyword in C++

#include<iostream>
using namespace std;
int main(){
int age=18
if(age>=18{

    cout<<"You can derive a car";
  }
else{
cout<<"You can not derive a car";
}

}
============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.

Register Keyword in C++

#include<iostream>
using namespace std;
int main(){
register int x=80;
cout<<"Value of Register x:"<<x;

}
============OUTPUT============
Value of Register x:80
Static Keyword: 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.

Static Keyword in C++

#include<iostream>
using namespace std;
int main(){
for(int i=1;i<=5;i++){
    static int x=0;
cout<<"Static value of x:"<<x++;
}
============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: sizeof Keyword can be used to find memory size of any data types. 

Sizeof Keyword in C++

#include<iostream>
using namespace std;
int main(){
int x=100;
float y=78.6;
char c='J';
double phone=969040;
cout<<"Size of Integer:"<<sizeof(x)<<endl;
cout<<"Size of Float:"<<sizeof(y)<<endl;
cout<<"Size of Character:"<<sizeof(c)<<endl;
cout<<"Size of Double:"<<sizeof(phone)<<endl;
}

============OUTPUT============
Size of Integer:4
Size of Float:4
Size of Character:1
Size of Double:8
Struct Keyword: 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. 

Struct Keyword in C++

#include<iostream>
using namespace std;
struct student{
int id;
float marks;
}s;
int main(){
s.id=101;
s.marks=89.8;
cout<<"Student id:"<<s.id<<endl;
cout<<"Student marks:"<<s.marks;

}
============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.   

Union Keyword in C++

#include<iostream>
using namespace std;
union student{
int id;
float marks;
}s;
int main(){
s.id=101;
s.marks=89.8;
cout<<"Student id:"<<s.id<<endl;
cout<<"Student marks:"<<s.marks;

}
============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. 

While Keyword in C++

#include<iostream>
using namespace std;
int main(){
int x=1;

   while(x<=5){
cout<<"value of x:"<<x<<endl;
x++
}
}
============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.


Post a Comment

0 Comments