C Program to perform all Arithmetic Operations

In this section, you will learn to read two integer number and C Program to perform all Arithmetic Operations (+,-,/,*,%).

For eg a=22 b=5

a+b = 27

a-b= 17

a*b = 110

a/b = 4

a%b = 2

C Program to perform all Arithmetic Operations


/* C-Program:Read two integer number and perform all arithmetic operation */
#include <stdio.h>

int main()
{
int x,y;
printf("Enter the values of x and y:\n");
scanf("%d%d", &x,&y);
printf("\nAddition (%d + %d) = %d \n", x,y,x+y);
printf("\ndifference (%d - %d) = %d \n", x,y,x-y);
printf("\nProduct (%d * %d) = %d \n", x,y,x*y);
printf("\nDivision (%d / %d) = %d \n", x,y,x/y);
printf("\nRemainder (%d %% %d) = %d \n", x,y,x%y);
return 0;
}

Output :-

Enter the values of x and y:
27 13

Addition   (27 + 13)  = 40

difference (27 - 13)  = 14

Product    (27 * 13)  = 351

Division   (27 / 13)  = 2

Remainder  (27 % 13)  = 1
Related Articles

Leave a Reply