## Introduction

It is very important to understand the computation of the division of two values. When both are of the same data type, and both are of different data types.

In this article, we will explore how to find the quotient and remainder when an integer gets divided by another integer.

To understand this program, you should know about the following:

1. Data types in C

2. Variables, literals, and constants

3. Operators in C

## Program

#include<stdio.h> int main() { int D,d,R,Q; // D=Dividend; d=Divisor; R=Remainder; Q=Quotient printf("Enter the value of Dividend:"); scanf("%d",&D); printf("Enter the value of Divisor:"); scanf("%d",&d); Q=D/d; // Computation of Quotient printf("%d is the Quotient\n",Q); R=D%d; //Computation of remainder printf("%d is the Remainder\n",R); return 0; }

## Output

## Explanation

Four variables are declared of ‘int’ data type as per the requirement of the program.

The user is then asked to enter the Dividend value and the divisor value that get stored at the address of variables ‘D’ and ‘d’, respectively.

**Q=D/d; **here we did the division part with the use of ‘/’ operator and calculated the quotient when ‘D’ is divided by ‘d’. Since both are of ‘int’ data type and we already know the quotient of two int values yields an int value as resultant. Thus, the final value is stored in the ‘Q’ variable of type ‘int’.

**R=D%d; **‘%’ modulo operator is used to calculate the remainder. Obviously, the remainder will be an integer value, that’s why assigned to a variable ‘R’ of ‘int’ data type.

Both values are printed on the screen, as shown in the output.

## 0 Comments