C Program to Compute Quotient and Remainder
In this example, we will learn to find the quotient and remainder when an integer is divided by another integer.
Remainder :
To understand this example, you must have the knowledge of the following C programming topics:
Program to Compute Quotient and Remainder
#include <stdio.h>
int main() {
int dividend, divisor, quotient, remainder;
printf("Enter dividend : ");
scanf("%d", ÷nd);
printf("Enter divisor : ");
scanf("%d", &divisor);
quotient = dividend / divisor;
remainder = dividend % divisor;
printf("Quotient is %d and Remainder is %d", quotient, remainder);
return 0;
}
Output
Enter dividend : 37
Enter divisor : 4
Quotient is 9 and Remainder is 1
Working of the above program
- First we declare integer character variables dividend, divisor to store the value of dividend and divisor entered by the user and remainder, quotient to store the results.
int dividend, divisor, quotient, remainder;
printf("Enter dividend : ");
scanf("%d", ÷nd);
printf("Enter divisor : ");
scanf("%d", &divisor);
quotient = dividend / divisor;
remainder = dividend % divisor;
printf("Quotient is %d and Remainder is %d", quotient, remainder);