How can I calculate divide and modulo for integers in C#?

前端 未结 5 1196
醉梦人生
醉梦人生 2020-12-01 11:28

How can I calculate division and modulo for integer numbers in C#?

5条回答
  •  醉梦人生
    2020-12-01 12:25

    Read two integers from the user. Then compute/display the remainder and quotient,

    // When the larger integer is divided by the smaller integer
    Console.WriteLine("Enter integer 1 please :");
    double a5 = double.Parse(Console.ReadLine());
    Console.WriteLine("Enter integer 2 please :");
    double b5 = double.Parse(Console.ReadLine());
    
    double div = a5 / b5;
    Console.WriteLine(div);
    
    double mod = a5 % b5;
    Console.WriteLine(mod);
    
    Console.ReadLine();
    

提交回复
热议问题