Wednesday, September 9, 2015

Arithmetic Instructions in C

type of instruction in c programming


In C programming an arithmetic instruction contains a variable on left side of =(assignment operator) and variables names and constants on right side of =(assignment operator).

Syntax:-    variable=(combination of variables and constants connected by arithmetic operators)
                 a=b+c-d*e/f;

Variables and constants together known as operands.

Variables and constants who appears on the right side of assignment operator connected by arithmetic operators like +,-,*,/ etc.

On the time of execution of an arithmetic statement first operands operated upon by the arithmetical operators and then the result assigned to the variable on the left hand side of =(assignment operator).

These arithmetic statements can be of 3 types as follows :-

1. Integer mode- All operands are of integer type.
                             for ex.- int a,b,c;
                             a=b+c+2;
2. Real mode- All operands are of real type.
                        for ex.- float a,b,c;
                        a=b+c+1.0;
3. Mixed mode- Some of the operands are integer type and some of the operands are of real type.
                           for ex.- int a,b;
                           float c,d;
                           d=a+b-c+2+3.5;

Points to note:-

1. Only one variable on left side of assignment operator.
              for ex.- a=b+c;  // correct
                           a+b=c; //Incorrect