Type Declaration Instruction:



This instruction is used to declare the type of variables being used in the program. A variable is a location in RAM (main memory) for temporary storage of intermediate data.
Any variable used in the program must be declared before using it in any statement. The type declaration statement is written at the beginning of main() function.

Ex:       int bas;
            float  rs, grosssal;
char  name, code;

These are several subtle variations of the type declaration instruction.

i) While declaring the type of variable we can also initialize it as shown below:

int i=10, j=25;
float a=1.5, b= 1.99+2.4 * 1.45 ;
ii)  The order in which we define the variables is sometimes important sometimes not.
      For exa:

            int i=10,j=20;

is same as
            int j=20, i=10;

However,

float a =1.2, b=a+3.1;
is alright, but

float b=a+3.1, a=1.2;

is not.this is because here we are trying to use a even before defining it.

iii) Similarly
            int a,b,c,d;
            a=b=c=10;
            is O.K. but

            int a=b=c=d=10;

            will not work.( find out why ???)

Popular posts from this blog

AGRICULTURAL SCIENTIST RECRUITMENT BOARD

HSC Exam Time Table 2013 Arts, Commerce, Science

What are cookies and its types? Where are cookies used?