Write a C program to perform all arithmetic operations on two integers

#include <stdio.h>
int main()
{
    int num1, num2;
    int sum, sub, mult, mod;
    float div;
    printf("Enter any two numbers: ");
    scanf("%d%d", &num1, &num2);
    /* Perform all arithmetic operations*/ 
    sum = num1 + num2;
    sub = num1 - num2;
    mult = num1 * num2;
    div = (float)num1 / num2;
    mod = num1 % num2;
    /*Print result of all arithmetic operations*/
    printf("SUM = %d\n", sum);
    printf("DIFFERENCE = %d\n", sub);
    printf("PRODUCT = %d\n", mult);
    printf("QUOTIENT = %f\n", div);
    printf("MODULUS = %d", mod);
    return 0; 
}

OUTPUT:
Enter any two numbers: 8
5
SUM = 13
DIFFERENCE = 3
PRODUCT = 40
QUOTIENT = 1.600000
MODULUS = 3

0 Comments:

Post a Comment