Q
Q
qwertynf2018-06-15 21:48:44
C++ / C#
qwertynf, 2018-06-15 21:48:44

How to request a number through cin in C++ so that it ends with the number 5?

I understand that the question is the dumbest, but I did not find a solution on the Internet (I would like to see the code as an answer)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mercury13, 2018-06-15
@qwertynf

This is impossible, the man is free to enter anything into the console.
But your task as a programmer is to somehow prevent incorrect input. Whether to display an error, or independently round, or require re-entry ... You yourself think what is required from your program.
The condition "ends in 5" is equivalent to "not divisible by 10, but divisible by 5".

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question