C Language

May 27, 2023

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

by : Nadeem Khan

Quick Summary:

In this will give two values 44 and 6 which will be deducted will be remainder which will not be deducted will be quotient