program a division algorithm for 32-bit integer in C language
时间: 2023-12-10 09:40:55 浏览: 83
Here is a simple division algorithm for 32-bit integer in C language:
```c
#include <stdio.h>
int main()
{
int dividend, divisor, quotient, remainder;
printf("Enter dividend: ");
scanf("%d", ÷nd);
printf("Enter divisor: ");
scanf("%d", &divisor);
quotient = dividend / divisor;
remainder = dividend % divisor;
printf("Quotient = %d\n", quotient);
printf("Remainder = %d\n", remainder);
return 0;
}
```
This algorithm takes two input integers, dividend and divisor, and calculates the quotient and remainder using the division and modulus operators in C language. The quotient and remainder are then printed to the console. Note that this algorithm does not handle division by zero, which should be checked separately.
阅读全文