C 程序以计算商数和余数?
提供被除数和除数两个数字。任务是编写一个程序,当被除数除以除数时,计算这两个数字的商数和余数。
在除法中,我们将看到被除数、除数、商数和余数之间的关系。我们求除数的数字称为被除数。我们求除的数字称为除数。所得结果称为商数。剩余的数字称为余数。
55 ÷ 9 = 6 and 1 Dividend Divisor Quotient Remainder
Input: Dividend = 6 Divisor = 2 Output: Quotient = 3, Remainder = 0
说明
然后,使用算术运算符 / 将变量被除数和除数除以商数;使用算术运算符 % 将变量余数除以余数。
示例
#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
", quotient);
printf("Remainder = %d", remainder);
return 0;
}
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 语言编程
C++
C#
MongoDB
MySQL
JavaScript
PHP