In this post, you will learn how to compute quotient and remainder when an integer is divided by another integer in C Programming language.

In the program, the user is asked to enter the dividend and divisor and the program then calculates quotient and remainder according to the input values.

So, Without further Ado, letâ€™s begin the tutorial.Â

**C Program To Compute Quotient and Remainder**

// C Program To Compute Quotient and Remainder #include <stdio.h> int main(){ int a, b, quotient, remainder; // Asking for Input printf("Enter the Dividend: "); scanf("%d", &a); printf("Enter the Divisor: "); scanf("%d", &b); // Calculate Quotient quotient = a / b; // Calculate Remainder remainder = a % b; // Displays Output printf("Quotient is: %d \n", quotient); printf("Remainder is: %d", remainder); return 0; }

**Output**

**Enter the Dividend:** 108
**Enter the Divisor:** 7
**Quotient is:** 15
**Remainder is:** 3

**How Does This Program Work ?**

**int a, b, quotient, remainder;**

In the above example, we have declared four integer data types variable named as a, b, quotient and remainder.

**// Asking for Input
printf("Enter the Dividend: ");
scanf("%d", &a);
printf("Enter the Divisor: ");
scanf("%d", &b);
**

Then, the user is asked to enter the input integers (dividend and divisor). The value of dividend and divisor is stored in **a** and **b** named variables respectively.

` `** // Calculate Quotient
quotient = a / b;
// Calculate Remainder
remainder = a % b;**

The quotient is calculated using **/** (division operator) and stored in the ** quotient** named variable.Â

Similarly, the remainder is calculated using** %** (modulo operator) and stored in the **remainder **named variable.

**// Displays Output
printf("Quotient is: %d \n", quotient);
printf("Remainder is: %d", remainder);**

Finally, the quotient and the remainder calculated in the previous step is displayed to the screen as output using **printf()** function.

Some used terms are as follow:Â

**#include <stdio.h>** – In the first line we have used #include, it is a preprocessor command that tells the compiler to include the contents of the stdio.h(standard input and output) file in the program.

The **stdio.h **is a file which contains input and output functions like** scanf()** and** printf()** to take input and display output respectively.

**Int main()** – Here main() is the function name and int is the return type of this function. The Execution of any Programming written in C language begins with main() function.

**scanf()** – scanf() function is used to take input from the user. Here **%d** indicates that we are reading Integer Data Type.

**printf()** – printf() function is used to display and print the string under the quotation to the screen.

**/** – Divides Numerator by Denominator and gives quotient. This is known as Division Operator.

**% **– It is known as Modulus Operator and provides remainder after division.

**// **– Used for Commenting in C

**Conclusion**

I hope after going through this tutorial , you clearly understood how to compute quotient and remainder in the C Programming language.

If you still have any doubt regarding the program, feel free to contact us in the comment Section. We will be delighted to help you.