Arithmetic operators are used to the total of numeric operands or string concatenation and save in a variable.
+ Addition (used to add two number)
– Subtraction (used to subtraction)
* Multiplication (used to multiply)
/ Division(used to divide)
% Modulus Operator (used to find remainder
Examples of arithmetic operators are
a=c + d
a=c - d
a=c * d
a=c / d
etc., here a,c,d are known as operands. The % is used in this expression to find the remainder of the operands after division.
#include<stdio.h> //header file
#include<conio.h> //header file
void main() //the start of the program
int c, d, total, sub, mul, div, mod; //declaration of variables
scanf (“%d %d”, &c, &d); //inputs the operands
total = c+d; //addition of numbers and store in total.
printf(“\n Thu total is = %d”, total);
sub = c-d; //subtraction of numbers and store in sub.
printf(“\n Thu difference is = %d”, sub);
mul = c*d; //multiplication of numbers and store in mul.
printf(“\n Thu product is = %d”, mul);
div = c/d; //division of numbers and store in div.
printf(“\n Thu division is = %d”, div);
mod = c%d; //modulus of numbers and store in mod.
printf(“\n Thu modulus is = %d”, mod);
When we do an arithmetic operation numbers or integers than this operation is called as integer arithmetic. It gives the integer as the result. Suppose c = 25 and d = 7 be 2 integer numbers. Then the integer operation leads to the following results.
c + d = 32
c - d = 18
c * d = 175
c / d = 4
c % d = 4
-19% 3 = -1
-19%-3 = -1
19%-3 = 1
In integer division the fractional part is truncated.
Floating point arithmetic
When we perform operation on two real numbers or fraction numbers then this operation is called floating point arithmetic.
Let x = 15.0 and y = 3.0 then
x + y = 18.0
x – y = 12.0
x * y = 545.0
x / y = 3.00
Void main ()
Mixed mode arithmetic
When one operand is real number and other is an integer number. Then operation between these operands called as mixed mode arithmetic. If any one operand is of real type then the result will always be real thus 15/10.0 = 1.5
Void main ()