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
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.
#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; }
以上就是计算商和余数的C程序?的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号