Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a function bool yes( ) which reads a string from the keyboard and returns

ID: 2990111 • Letter: W

Question

Write a function bool yes( ) which reads a string from the keyboard and returns true if the string begins with 'Y' or 'y'; otherwise it returns false. Now write a main to play a simplified version of "Twenty Questions" which asks only three yes/no questions and calls yes( ) to get the user's answers and deduce which of eight items matches. A sample run should look like this:

Are you thinking of something that is alive? No
Are you thinking of a Sesame Street character? Yup
Are you thinking of something that is green? yessiree

Explanation / Answer

bool yes(){

char arr[5];

int i;

for (i=1;i<5;i++){

cin>> arr[i];

}

if(arr[0] == 'y' || arr[0]=='Y'){

return true;

}else{

return false;

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote