Pages

Monday, 21 October 2013

Constants, Variables and Keywords in C++

Constants:

             If we declare Identifier as constant then we can not change value of the Identifier during execution of the Program.

  • Identifier is name of the variable 

Numerical Constants:

Integer Constants:

Sequence of the Numbers from 0 to 9 except decimal points
Integer Constants are neither Positive nor Negative or Zero.
Ex: 25, 63,852,  -45 ,-90 , 0 …etc.

Real Constants:

The floating points or decimal points is knows as Real Constants.
Ex: 63.25, -963.2 …etc.

Complex Constants:

Complex constants are divided into 2 parts
1. Real Part
2. Imaginary Part.

In Real and Imaginary part we will take Real values.

Character Constants:

Single Character Constants:

The Character is called a Single Character Constants and it is enclosed with in the single quotes ( ‘  ‘).
Ex: ‘d’ , ‘c’ ,….etc.

String Constants:

Group of character or collections of characters are called String Constants and it is enclosed with the double quotes (“ “).

Ex: “c language “, “ “56+23”, “string constants”:…etc.

Boolean Constants:

0 or 1 called Boolean Constants.

Coding Constants:

Literal Constants:

Unchanged values in the expression is called literal constants.

Ex; 2x+4y=15 here 2,4,15 unchanged values.

Defined Constants:

Defined constants are used in macros and file inclusion … etc.
#define size 5, #define pi 3.14 …etc.

Memory Constants:

Memory constants are unchangeable if we initialize the value once we can’t reinitialize.
 Ex: const int a=10 ,const int x=25 ..etc.

Variable:

Variable is name of the memory location whose value can be change from time to time.
Ex: a, x, sname , vage , ..etc.

Key words or Reserved Words:

In c and c++ the meaning of the Keywords and content of the Keywords already defined. We can not change meaning of the key word or content of the keywords.

key words: (reference from  ashok N kamthane text book)



No comments:

Post a Comment