Question: Write a function named magic 8 ball. It should accept a question ( written as a char array ) as an input and return an

Write a function named magic8ball. It should accept a question (written as a chararray) as an input and return an output answer written as a chararray. You should check that the user entered a question by looking for the question mark character '?' as the last element of the chararray. If the question does not end with a question mark, return the statement 'You did not ask a question.'
If it is a question, then generate a random number and return one of several (at least 4) different answers based on that random number (e.g. 'yes', 'no', 'maybe', 'ask someone else', etc. Have fun with this part!). Use the randiand switchcommands in your code.
Tip: == only works on single characters. Use strcmpif you want to check equality between arrays of multiple chars.
Note: in this problem, we want you to work with chararrays, not strings.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!