die's job is to output an error message alarmingly and terminate the program. You may copy...

60.1K

Verified Solution

Question

Programming

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!

Answer & Explanation Solved by verified expert
4.1 Ratings (819 Votes)
4CCodeOutputSnapshotTextCodeinclude using namespace stdint main Character Variable to store    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students