C Program to Compute Quotient and Remainder

76
views
Compute Quotient Remainder
(Last Updated On: September 1, 2018)

This program evaluates and Compute Quotient Remainder when an integer is divided by another integer.

To understand this Program to Compute Quotient Remainder, you should have the knowledge of following C programming topics:

Program to Compute Quotient and Remainder

#include <stdio.h>

int main()
{
	int dividend, divisor;
	int quotient, remainder;
	
	printf("Enter dividend: ");
	scanf("%d",&dividend);

	printf("Enter divisor: ");
	scanf("%d",&divisor);
	
        // Computes quotient 
	quotient= dividend/divisor;

        // Computes remainder
	remainder= dividend%divisor;
	
	printf("quotient: %d, remainder: %d\n",quotient,remainder);
	
	return 0;
}

Output

Enter dividend: 25
Enter divisor: 4
Quotient = 6
Remainder = 1

C Program to Compute Quotient and Remainder

In this program, the user is asked to enter two integers (dividend and divisor) which are stored in variable dividend and divisor respectively.

Then the quotient is evaluated using division/operator and stored in the variable quotient.

Similarly, the remainder is evaluated using modulus % operator and stored in remainder variable.

Finally, the quotient and remainder are displayed using printf() function.

Related C Programs

Ask your questions and clarify your/others doubts on C Program to Compute Quotient and Remainder by commenting. Documentation