c
  1. c-program-to-compute-quotient-and-remainder

Program to Compute Quotient and Remainder (C Programs)

Heading

This program computes and prints the quotient and remainder of two integers provided by the user.

Example

#include <stdio.h>

int main() {
   int dividend, divisor, quotient, remainder;

   printf("Enter dividend: ");
   scanf("%d", &dividend);

   printf("Enter divisor: ");
   scanf("%d", &divisor);

   quotient = dividend / divisor;
   remainder = dividend % divisor;

   printf("Quotient = %d\n", quotient);
   printf("Remainder = %d\n", remainder);

   return 0;
}

Output

Enter dividend: 35
Enter divisor: 4
Quotient = 8
Remainder = 3

Explanation

The program takes input of two integers, dividend and divisor, and computes their quotient and remainder using the modulo and division operators respectively. The quotient and remainder are then printed to the console.

Use

This program is useful in solving mathematical problems involving division of integers and finding out the quotient and remainder of the division.

Summary

This program is a simple and efficient way to compute and output the quotient and remainder of two integers provided by the user.

Published on: