Friday, September 2, 2016


C Arithmetic Program — Sum, Product, Difference, Quotient, Remainder

Question: Write a program that asks the user to enter two numbers, obtains them from the user and prints their sum, product, difference, quotient and remainder.

 * Website: 
 * Program to calculate the sum, product, difference, quotient and remainder
 * of two numbers entered by the user.

#include <stdio.h>
int main (){
    int num1, num2, sum, prod, diff, quot, rem;
    puts("Enter two numbers: ");
    scanf("%d%d", &num1, &num2);
    sum = num1 + num2;
    prod = num1 * num2;
    diff = num1 - num2;
    quot = num1 / num2;
    rem = num1%num2;
    printf("The sum of %d and %d is %d.\n", num1, num2, sum);
    printf("The product of %d and %d is %d.\n", num1, num2, prod);
    printf("The difference of %d and %d is %d.\n", num1, num2, diff);
    printf("The quotient of %d and %d is %d.\n", num1, num2, quot);
    printf("The remainder of %d and %d is %d.\n", num1, num2, rem);
    return 0;

C Arithmetic Program output
Program output
Click here to see other solutions to Deitel C How To Program exercises.


  1. where is the quotient line?

  2. Please need a procedure of a c program that accepts two numbers from the user computes their product and sum


DISCLAIMER: Opinions expressed in comments are those of the comment writers alone and does not reflect or represent the views of the post author. We reserve the right to delete any post deemed inappropriate or offensive and/or spammy. Please do not use abusive words/hate speech.

I Appreciate your valuable Feedback. So, Please DO NOT SPAM - Spam comments will be deleted immediately.

Don't use brand name in name field and you're not allowed to use links in comments unless it's necessary. Such comments will be removed immediately. To get notified of replies or follow-up comments, click the box next to notify me.