# 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 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 integers values and q is quotient and r is remainder values respectively.

## Program Code – Remainder and Quotient

`#include <stdio.h>    #include<conio.h>    main()  {        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("_");printf("\n\n");            printf ("Quotient = %d\n", quotient);            printf ("Remainder= %d\n", remainder);        for(i=0;i<20;i++)        printf("_");printf("\n");        getch ();        return 0;  }   `

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

`quotient = dnd/div;       remainder = dnd % div;`

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

## Output

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

Related Articles: