Reading the Input Data

We take n from the console and we save it in a variable of type int.

It is very important to check if the input data is correct! In these problems it is not a problem to directly convert the data from the console into int, because it is said that we will receive valid integers. If you are making more complex programs it is a good practice to check the data. What will happen if istead of the character "А" the user inputs a number?

results matching ""

    No results matching ""