# C Program to calculate out Quotient and Remainder

|In this C Programming example, we will implement the program to find out the quotient and remainder of the numbers entered by the user and print the output on the console.

Table of Contents

## 1. Quotient and Remainder

In the following program, based on the user’s input the quotient and remainder are calculated using a ** user-defined function**.

ExampleInput:Dividend is: 6 Divisor is: 2Output:Quotient is: 3 Remainder is: 0

Helpful topics to understand this program better are-

## 2. C Program to find out the quotient and remainder

Let’s discuss the execution(kind of pseudocode) for the program to find out the quotient and remainder of the numbers entered by the user in C.

- Initially, the program will prompt the user to enter the two numbers. The values are then stored in
**dividend**and**divisor**accordingly. - Then we call a function to calculate the
**quotient and remainder**,`q = quotient(number1, number2)`

and`r = remainder(number1, number2)`

and store the result in`q`

and`r`

respectively. - We print the quotient(
**q**) and the remainder(**r**) on the console.

Let us now implement the above execution of the program *to find out the quotient and remainder in C.*

#include <stdio.h> int quotient(int x, int y){ return x / y; } int remainder(int x, int y){ return x % y; } int main(){ int number1, number2, q, r; printf("Enter the dividend: "); scanf("%d", &number1); printf("Enter the divisor: "); scanf("%d", &number2); q = quotient(number1, number2); r = remainder(number1, number2); printf("Quotient is: %d\n", q); printf("Remainder is: %d", r); return 0; }

**Note:** The numbers entered must be of integer data type, but the code can be formatted for other data types like- float, double.

OutputEnter the dividend: 5 Enter the divisor: 2 Quotient is: 2 Remainder is: 1

## 3. Conclusion

In this C Programming example, we have discussed *how to find out the quotient and remainder* *in C*.

**Helpful Links**

Please follow **C Programming tutorials** or the **menu in the sidebar** for the complete tutorial series.

Also for the example C programs please refer to **C Programming Examples**.

All examples are hosted on **Github**.

**An investment in knowledge always pays the best interest. I hope you like the tutorial. Do come back for more because learning paves way for a better understanding**

**Do not forget to share and Subscribe.**

* Happy coding!! *😊