How to use quotient and remainder in C Language
Quotient and Remainder
On this page
Quotient and Remainder
Program to use Quotient and Remainder in C Language
#include <stdio.h>
int main()
{
int x, y, quo, rem;
printf("Enter two number : ");
scanf("%d%d", &x, &y);
if (y)
{
quo = x / y;
rem = x % y;
printf("Quotient = %d, Remainder=%d\n", quo, rem);
}
else
{
printf("Divide by zero error\n");
}
return 0;
}
Output
Enter two number : 44
6
Quotient = 7, remainder = 2
Steps Description
- Declare integer variable x, y, quo, rem
- printf inbuild function to display will give two numbers
- Pass to values to scanf
- If condition
- which will give value divided into x and y
- printf inbuild function to display the value of quo ,rem