C Program To Find Reminder And Quotient

This program uses a division operator on two input numbers. The output is a quotient and a remainder is printed to the console.


We compiled the program using Turbo C++ 3.0 running in a DOS Box 0.74  on a Windows 7  64-bit system. You may try the program using a different standard C compiler, but make necessary changes to the source code.

Learn the following concepts before you try this example program.

Problem Definition

When the program runs, it ask for two input numbers, a and b. The number a is dividend and b is divisor for the program which uses division operator (/) to divide the numbers and return the results.

The program performs the simple division as follows,

&q = a/b\\ \\
&r = a % b

Where a and b are two integer values and q is quotient and r is remainder values respectively.

Flowchart – Program to find Quotient and Remainder

Flowchart – C Program to Find Quotient and Remainder

Program Code – Remainder and Quotient

#include <stdio.h>
#include <conio.h>
    int dnd, div, quotient, remainder;
    int i;
    //Enter Input Numbers 'a' and 'b'
    printf ("Enter the dividend:");
    scanf ("%d", &dnd);
    printf ("Enter the divisor :");
    scanf ("%d",&div);
    //Compute Quotient and Remainder
        quotient = dnd/div;
        remainder = dnd % div;
     //Print the Results
      for(i=0;i < 20;i++)
        printf ("Quotient = %d\n", quotient);
        printf ("Remainder= %d\n", remainder);
    getch ();
    return 0;

The most important code in the above program is as follows.

quotient = dnd/div \\ \\
&remainder = dnd \hspace{1mm} \%  \hspace{1mm}div;

The values of quotient and remainder is printed to console before the program terminates.


In the results below, 34 is divided by 6 and results in quotient = 5 and remainder = 4 because

a = q * b + r \\ \\
&34 = 5 * 6 + 4\\ \\
&= 30 + 4
                     Enter the dividend:34
                     Enter the divisor :6
                     Quotient = 5
                     Remainder= 4

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Exit mobile version