Menu Close

Compute all Arithmetic Operations

Rathik_1 organized technical round interview in Macrosoft for the set of computer science candidates.The problem is to perform addition, subtraction, multiplication, and division of given two numbers. Rathik_1 have given the deadline of only 5 minutes to complete the problem.

Input: 
The only line of input has two numbers a and b of type integers separated by a comma. 

Output: 
Print Addition, Subtraction, Multiplication, Division, and Modulus of given two numbers in a separate line respectively.

Note: Rathik_1 instructed his candidates to print the  result of the division  with 3 values after decimal point.
#include <stdio.h>
int main()
{
    int testnum1,testnum2;
    int sum,sub,mult,mod;
    float div;
    scanf("%d",&testnum1);
    scanf("%d",&testnum2);
    sum=testnum1+testnum2;
    sub=testnum1-testnum2;
    div=(float)testnum1/(float)testnum2;
    mult=testnum1*testnum2;
    mod=testnum1%testnum2;
    printf("\nAddition : %d",sum);
    printf("\nSubtraction : %d",sub);
    printf("\nMultiplication : %d",mult);
    printf("\nDivision : %0.3f",div);
    printf("\nModulus : %d",mod);
	return 0;
}

Input_1:
17  13

Output:
Addition :  30
Subtraction :  4
Multiplication :  221
Division :  1.308
Modulus :  4


Input_2:
31  4

Output:
Addition : 35
Subtraction : 27
Multiplication : 124
Division : 7.750
Modulus : 3


ILLUSTRATION

Executed using gcc Linux

Morae Q!