CBCS C Program to Compute Quotient and Remainder

Dear Readers, This program evaluates the quotient and remainder when an integer is divided by another integer.

To understand this example i.e CBCS C Program to Compute Quotient and Remainder, you should have the knowledge of following C programming topics:

  • C Programming Data Types
  • C Programming Constants and Variables
  • C Programming Input Output (I/O): printf() and scanf()
  • C Programming Operators

# CBCS C Program to Compute Quotient and Remainder

#include <stdio.h>
int main(){

int dividend, divisor, 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\n", quotient);
 printf("Remainder = %d", remainder);

return 0;
}

Output

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

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

Then the quotient is evaluated using division / operator and stored in 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.

Learn more on how division / and modulus operator % operator works in C programming.

We hope you enjoyed to read this page. If you have any questions, please comment below!

Previous                               Main Menu                               Next Page

Leave a Reply

Your email address will not be published.