How to use quotient and remainder in C Language

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

  1. Declare integer variable x, y, quo, rem
  2. printf inbuild function to display will give two numbers
  3. Pass to values to scanf
  4. If condition
  5. which will give value divided into x and y
  6. printf inbuild function to display the value of quo ,rem