计算商和余数的C程序?

2023年 8月 30日 66.5k 0

计算商和余数的C程序?

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

登录后复制

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

登录后复制

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
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;
}

登录后复制

以上就是计算商和余数的C程序?的详细内容,更多请关注每日运维网(www.mryunwei.com)其它相关文章!

相关文章

JavaScript2024新功能:Object.groupBy、正则表达式v标志
PHP trim 函数对多字节字符的使用和限制
新函数 json_validate() 、randomizer 类扩展…20 个PHP 8.3 新特性全面解析
使用HTMX为WordPress增效:如何在不使用复杂框架的情况下增强平台功能
为React 19做准备:WordPress 6.6用户指南
如何删除WordPress中的所有评论

发布评论