Before going to the tasks, we are going to revise the most important aspects of what we have studied in the previous chapter. We will start with reading numbers from the console.
We need to create a variable to store the integer (for example,
num) and use a standard command for reading input from the console, combined with the function
int.Parse(…) which converts string to an integer:
var num = int.Parse(Console.ReadLine());
We read a decimal number, the same way we read an integer one, but this time we use the function
var num = double.Parse(Console.ReadLine());