-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModuloOperations.cs
More file actions
29 lines (23 loc) · 985 Bytes
/
Copy pathModuloOperations.cs
File metadata and controls
29 lines (23 loc) · 985 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/* Given three integers, write a method that returns first number divided modulo by second one and these divided modulo by third one.
* https://csharpexercises.com/basics/exercise/modulo-operations
*/
using System;
namespace ProgrammingExercises {
class Program {
// ModuloOperations(8, 5, 2) → 1
public static void GetModThreeNums(int numOne, int numTwo, int numThree) {
Console.WriteLine($"The value of {numOne} % {numTwo} = {numOne % numTwo}, and that % {numThree} = {((numOne % numTwo) % numThree)}");
}
public static int GetNumber() {
int num = 0;
Console.Write("Please enter an integer: ");
while (!int.TryParse(Console.ReadLine(), out num)) {
Console.Write("Please enter a valid integer: ");
}
return num;
}
static void Main(string[] args) {
GetModThreeNums(GetNumber(), GetNumber(), GetNumber());
}
}
}