Write a C# Sharp program to calculate the quotient of two 32-bit signed integers and also returns the remainder in an output parameter
- برمجة سي شارب
- برمجة
- 2021-05-31
- ahmadghneem
الأجوبة
using System;
using System.Text;
namespace exercises {
class Program {
public static void Main()
{
// Define several positive and negative dividends.
int[] dividends = { Int32.MaxValue, 23547, 0, -12547,
Int32.MinValue };
// Define one positive and one negative divisor.
int[] divisors = { 4000, -4000 };
foreach (int divisor in divisors)
{
foreach (int dividend in dividends)
{
int remainder;
int quotient = Math.DivRem(dividend, divisor, out remainder);
Console.WriteLine(@"{0:N0} \ {1:N0} = {2:N0}, remainder {3:N0}",
dividend, divisor, quotient, remainder);
}
}
}
}
}
أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال