Write a C program to find the quotient and remainder. For example, a = 17, b = 5. As we know, 5 * 3 = 15, so 3 is the quotient and the remainder (17 -15) = 2. This example program allows the user to enter two integer values and uses the / and % operators to compute the quotient and remainder.
#include <stdio.h>
int main()
{
int number1, number2;
float quotient, remainder;
printf("Enter the Number to perform Division = ");
scanf("%d",&number1);
printf("Enter the Divisor Number = ");
scanf("%d",&number2);
quotient = number1 / number2;
remainder = number1 % number2;
printf("The Quotient of %d and %d = %.2f", number1, number2, quotient);
printf("\nThe Remainder of %d and %d = %.2f\n", number1, number2, remainder);
}

In the example above, the division operator (/) calculates the quotient and stores it in the quotient variable.
quotient = number1 / number2;
The following statement uses the modulo operator (%) to find the remainder. Please refer to the Arithmetic Operators in C.
remainder = number1 % number2;
Program to find the quotient and remainder using functions
In this C program, the two user-defined functions accept two integer values and find the quotient and remainder.
#include <stdio.h>
float calcQuot(int a, int b) {
return a / b;
}
float calcRem(int a, int b) {
return a % b;
}
int main()
{
int num1, num2;
float quot, rem;
printf("Enter the Number = ");
scanf("%d",&number1);
printf("Enter the Divisor Number = ");
scanf("%d",&number2);
quot = calcQuot(num1, num2);
rem = calcRem(num1, num2);
printf("The Quotient of %d and %d = %.2f\n", num1, num2, quot);
printf("The Remainder of %d and %d = %.2f\n", num1, num2, rem);
return 0;
}
Enter the Number = 229
Enter the Divisor Number = 5
The Quotient of 229 and 5 = 45.00
The Remainder of 229 and 5 = 4.00
Also Read