Monday, 30 December 2013

Filled Under:

Declaration of variables:

Declaration of variables:

                                         In order to use variable in c++ we must declare a variable . declaration mean specify the data  which store in the variable.
The syntax of declaration of variable is 

syntax:

Int a;
Char c;
Float number;

Explanation:

                                In the first statement variable name is ‘a’ and int is its data type . it mean variable a reserve the space in the memory which only can store integer type value. Every statement in c++ is end with semicolon . similarly in the second statement variable ‘c’ store the character value . variable ‘number’ store the float value .

Note:

     if we store the value 4 in number variable whose data type is float . whenever ‘4’  is integer value so the compiler take ‘4’ as ‘4.0000’ which is now become a floating value.

More example:

       Int a;
       Int b;
       Int c;
Here is three variable a, b and c which has same data type .so we can declare these three as single statement so we can write it as 
     Int a,b,c;
So now we can say that if the variable which has the data type can declare it single statement rather than declare it more than one statement.




0 comments:

Post a Comment