0
C++ program question
Random generator. How do I get the user to guess a number and the program to output if the guessed number is too high or too low?
1 Answer
+ 2
I guess you mean something like this:
https://code.sololearn.com/c6tjYD99i071/?ref=app
This is the simplest way to generate a random number:
https://www.sololearn.com/learn/CPlusPlus/1638/
https://en.cppreference.com/w/cpp/numeric/random/rand
A somewhat better alternative would be to make use of the <random> header instead, but that is likely to be over the top if you are just starting out or don't care about the quality of the random implementation too much:
https://en.cppreference.com/w/cpp/header/random
The rest is just the input, an if-decision and some output, all together in a loop, which shouldn't be hard to write. Have a look at the code above and take it from there.