What are the difference between Keywords and Identifiers in C++ language?

In C++ language, Keywords and Identifiers both are tokens and have their own importance and meaning. Below we discuss some important feature and difference between these two tokens with respect to C++ language.  


1. Keywords are the reserved words which have some meaning in itself and we cannot use these words for another purpose. But identifiers are the user defined words which are used for specific purpose in programming like declare a variable or function name. For example, int x=10, here int is a keyword because int have a reserved word for integer and x is a identifiers which is used as variable name. and 10 is a constant value.

2. Keywords meaning are defined already in compiler, but identifiers meaning varies according to the programmer. For Example: int x=10, here int is used for integer only and x as an identifier for integer variable. Lets take another example, char x = 'c', here char is used for character variable but x is used for identifiers as character variable. so x have different meaning as defined by programmer. 

3. All the keywords are defined by using character but in declaring identifiers we can also use digits ( 0-9) and some special characters also.

4. In C++ language there are only 62 keywords, but we can declare as many as identifiers in our program according to program requirement.

5. In keywords only lowercase letter are used, but for declaring identifiers we can also use uppercase letter like (A-Z), lowercase (a-z), digits (0-9) and underscore ( _) or any combination or these. Refer identifiers rules.




Thanks
Mukesh Rajput


Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:

0 comments: