C Program for Arithmetic Operations

In this source code example, we will write a C program to accept 2 numbers and compute all arithmetic operations.

C Program for Arithmetic Operations

In this C program, we will take input from the User or console and print the result to the output: 

    int num1,num2;
    /*Accept two numbers from user*/
    printf("Enter first number: ");
    printf("Enter second number: ");
    /*Display values for arithmetic operators*/
    printf("Sum of 2 numbers: %d",num1+num2);
    printf("\nDifference of 2 numbers: %d", num1-num2);
    printf("\nProduct of 2 numbers: %d", num1*num2);
    printf("\nQuotient for %d/%d: %d", num1,num2,num1/num2);
    printf("\nRemainder for %d/%d: %d", num1,num2,num1%num2);


Enter first number: 20
Enter second number: 10
Sum of 2 numbers: 30
Difference of 2 numbers: 10
Product of 2 numbers: 200
Quotient for 20/10: 2
Remainder for 20/10: 0