C++ Keywords

Keywords are the words that convey a special meaning to the language compiler. These are the reserved words for special purpose and must not be used as normal identifier names.

C++ Complete Keywords List

Following table lists the Complete C++ Keywords :

Keywords Newer Keywords
asm continue float new signed try using
auto default for operator sizeof typedef namespace
break delete friend private static union bal
case do goto protected struct unsigned static_cast
catch double if public switch virtual const_cast
char else inline register template void dynamic_cast
class enum int return this volatile true
const extern long short throw while false

Note : Identifiers containing a double underscore (_ _) are reserved for use by C++ implementations and standard libraries and should be avoided by users.

C++ Keywords Example

Following example shows the uses of some of the C++ keywords :

/* C++ Keywords Example */


void main()
   /* This program uses the following
      C++ keywords (most widely used) :
      for, if, else, int */
   int num, times, i;
   cout<<"Enter a number between 1...99 ";
   if(num>0 && num<100)
      cout<<"What an honest employee!!";
      cout<<"Bad employee!!";
   cout<<"\nEnter number of seconds to blast the Bomb : ";
   for(i=times; i>0; i--)
      cout<<i<<" ";

When the above C++ program is compile and executed, it will produce the following output:

c++ keywords

Above program is just example of showing the uses of C++ keywords (if, for, else, int), So don't be confuse with the sound action, this is just a part of C++ Graphics.

Note - To perform the sound action on your own computer/laptop using TurboC++ compiler, you have to make following changes :

  • Go to your computer's C drive
  • Open TurboC++ folder
  • Now open Disk > TurboC3 > BGI
  • Now copy EGAVGA.BGI files and place this file in the BIN directory
  • Now copy the above C++ program code in your TurboC++ compiler and run
  • You will hear sound from the above C++ program in the Bomb Blast Section.

Let's look at one more example on C++ keywords, this C++ program uses the these C++ keywords: char, do, while, switch, break, and default

/* C++ Keywords Example2 */

/* This C++ program uses the
   following keywords :
   char, do, switch, while, break,
   default */


void main()

   char choice, name[15], rollno, marks;

      cout<<"\n1. Enter Your Name\n";
      cout<<"2. Enter Your Roll No.\n";
      cout<<"3. Enter Your Marks\n";
      cout<<"4. Exit\n";
      cout<<"Enter desired Option (1-4) : ";
         case '1' : cout<<"What is your Name ? ";
            cout<<"Your Name is "<<name;
         case '2' : cout<<"What is Your Roll Number ? ";
            cout<<"Your roll number is "<<rollno;
         case '3' : cout<<"Enter Marks obtained in the examination : ";
            cout<<"You got "<<marks;
         case '4' : cout<<"press any key to exit...";
         default : cout<<"You entered out of 1...4";
   }while(choice != 4);


When the above C++ program is compile and executed, it will produce the following output:

keywords in c++ programming

Note - If you have any problem in understanding the concepts of the above programs, then just leave it, and go further, you will learn all the concepts in the separate chapters later.

More Examples

Here are some more C++ example programs listed, that you can go for:

C++ Online Test

« Previous Tutorial Next Tutorial »

Follow/Like Us on Facebook

Subscribe Us on YouTube