Home > Backend Development > C++ > body text

C program to calculate quotient and remainder?

王林
Release: 2023-08-29 21:21:05
forward
1462 people have browsed it

C program to calculate quotient and remainder?

Given two numbers dividend and divisor. The task is to write a program to find the quotient and remainder of these two numbers when the dividend is divided by the divisor.

In division, we will see the relationship between the dividend, divisor, quotient, and remainder. The number which we divide is called the dividend. The number by which we divide is called the divisor. The result obtained is called the quotient. The number left over is called the remainder.

55 ÷ 9 = 6 and 1
Dividend Divisor Quotient Remainder
Copy after login

Input:
Dividend = 6
Divisor = 2
Output:
Quotient = 3,
Remainder = 0
Copy after login

Explanation

Then, the variables Dividend and Divisor are divided using the arithmetic operator / to get the quotient as result stored in the variable quotient; and using the arithmetic operator % to get the remainder as result stored in the variable remainder.

Example

#include <stdio.h>
int main() {
   int dividend, divisor, quotient, remainder;
   dividend= 2;
   divisor= 6;
   // Computes quotient
   quotient = dividend / divisor;
   // Computes remainder
   remainder = dividend % divisor;
   printf("Quotient = %d</p><p>", quotient);
   printf("Remainder = %d", remainder);
   return 0;
}
Copy after login

The above is the detailed content of C program to calculate quotient and remainder?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template