Solution - part II

Second method: As we already know, the operator for division / operates differently on integers and decimals. When dividing integer with integer, the result is also an integer. Therefore, we can search how to convert the real numbers, which we have as values for the heigth and the width, into integers and then divide them.

In this case, there could be data loss after having removed the fractional part, so it is necessary that it is converted expressly (explicit typecasting). We use the operator for converting data (type) by replacing the word type with the needed data type and place it before the variable. (you can learn more about data type conversion here Svetlin Nakov, Veselin Kolev and team: "Programming Basics with C#", стр. 153-157)

With Console.WriteLine(…) we print the result on the console.

Test in the Judge system

Test your solution here:

results matching ""

    No results matching ""