The four most common arithmetic operators are +, -, * and / for addition, substraction, multiplication and division are used in same way as regular algebric calcluations. Modulus operator is a new operator represented by percent (%) symbol, which computes the remainder of division operation, also called as remainder operator. These operators work on data types like integer, float and double.
Below is an example that shows the use of arithmetic and modulus operators.
//Using arithmetic operators
printf("Enter value of a : ");
printf("Enter value of b : ");
printf("\nAddition is : %d",c);
printf("\nSubstraction is : %d",c);
printf("\nMultiplication is : %d",c);
printf("\nDivision is : %.2f",fc);
printf("\nRemainder is : %d",c);
Program working steps
First line is the comment, 2nd and 3rd line are preprocessor directive statements which include definition of printf, scanf, clrscr functions.
Void main() is the function where program execution starts.
Declaration of some integer and float variables.
Printf statement displays the output to enter the number and scanf stores the input number entered into the variable.
At line no.14 c=a+b; statement adds the value of a and b variable, and stores the result in variable c. Similar to this statement others statement on line no.16,18,22 and 24 results are being calculated and displayed accordingly.