Arithmetic Instructions can be classified in three categories
- Integer Mode Arithmetic Instruction
- Real Mode Arithmetic Instruction
- Mixed Mode Arithmetic Instruction
Integer Mode Arithmetic Instruction
In Integer Mode Arithmetic Instruction all the operands are integer and result is also integer.
int a,b,div; a = 21; b = 2; div = a/b; printf("Division = %d",div);
Output
Division = 10
In above program 21 divided by 2 and expected result will be 10.5 but both variable a and b are integers so their output is 10
Real Mode Arithmetic Instruction
In Real Mode Arithmetic Instruction all the operands are real numbers and result is also a real number.
float a,b,div; a = 21.0; b = 2.0; div = a/b; printf("Division = %d",div);
Output
Division = 10.500000
Mixed Mode Arithmetic Instruction
In Mixed Mode Arithmetic Instruction some operands are integer and some are real numbers and result is a real number.
int a; float b,div; a = 21; b = 2.0; div = a/b; printf("Division = %d",div);
Output
Division = 10.500000