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.
auto | break | case | char | const |
double | else | enum | extern | float |
int | long | register | return | short |
struct | switch | typedef | union | unsigned |
continue | default | do | for | goto |
if | signed | sizeof | static | void |
volatile | while |
The following is the list of 30 keywords in C++ that are not available in C programming language.
asm | dynamic_cast | namespace | reinterpret_cast | bool |
explicit | new | static_cast | false | catch |
operator | template | friend | private | class |
this | inline | public | throw | const_cast |
delete | mutable | protected | true | try |
typeid | typename | using | virtual | wchar_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:
1 2 3 4 5 6 7 8 9 10 | //Valid Number result1 _multiply S2C //Invalid Number-2 //special character '-' is present. 3Sum //started with digit int // int is a keyword |