C++ Keywords and Identifiers2 min read

Keywords

A keywords are the reserved words in programming language with a specific features for each keyword. Keywords always starts with the lower case and cannot be a variable name or constant name. These are predefined by the program and their value cannot be changed.

Example: int, float, public, etc.

The following is the list of 30 keywords in C++ that are also available in C programming language.

autobreakcasecharconst
doubleelseenumexternfloat
intlongregisterreturnshort
structswitchtypedefunionunsigned
continuedefaultdoforgoto
ifsignedsizeofstaticvoid
volatilewhile

The following is the list of 30 keywords in C++ that are not available in C programming language.

asmdynamic_castnamespacereinterpret_castbool
explicitnewstatic_castfalsecatch
operatortemplatefriendprivateclass
thisinlinepublicthrowconst_cast
deletemutableprotectedtruetry
typeidtypenameusingvirtualwchar_t

Identifiers

Identifiers are nothing but the name assigned to the entities such as variables, functions, arrays, or other user-defined data types. Identifiers are the basics need of programming language.

The name assigned to the entities is unique so that it can be identified during the execution of the program. Identifiers cannot be used as Keywords.

Example: int number;, number being an identifier.

Rules for naming identifiers:

  • Identifiers are case-sensitive that is uppercase and lowercase letters are distinct.
  • The first letter of identifiers must be a letter or underscore. After the first letter, you can use digits.
  • White spaces are not allowed.
  • A keyword cannot be used as an identifier.

Some valid and invalid identifiers:


MORE

Keith Number Program in C

In this tutorial, we will write a Keith number in C. It is one of the most asked questions in an interview. Before that, you …
Read More

Keith Number Program in C++

In this tutorial, we will write a Keith number in C++. It is one of the most asked questions in an interview. Before that, you …
Read More

Singly linked list Program C++

In this tutorial, we will write a C++ program to implement singly linked list. In this program, we will create a separate function for each …
Read More

Fascinating Number Program in C

In this tutorial, we will write a C program to check whether the given number is a Fascinating number or not. You may go through …
Read More

Peterson Number in C

In this tutorial, we will learn about the Peterson number and check if the number is Peterson or not in C. What is Peterson Number? …
Read More

Peterson Number in C++

In this tutorial, we will learn about the Peterson number and write a C++ program to check if the given number is a Peterson number …
Read More