die's job is to output an error message alarmingly and terminatethe program. You may copy my
function definition, or use your own:
// The following 4 lines should be present if we have a diefunction:
#include // cout, endl
#include // string
#include // exit, EXIT_FAILURE
using namespace std;
bool die(const string & msg){
cout <<\"Fatal error: \" <exit(EXIT_FAILURE);
}
4. Use rand to randomly choose one of the five operators * / % +- .
Use rand again to choose a random int in the range [1, 20].
Use rand again to choose a second random int in the range [1,20].
Ask the user what the answer to the corresponding equationis.
C&d on input failure
Tell the user whether he's correct.
An example run of your program might go as
What's the answer to 14 * 3 ?
42
Yes, that's the right answer!