Dev C++ Yes Or No Question

Posted on  by
  1. Dev C Yes Or No Question Questions
  2. Dev C Yes Or No Question Game
  3. Dev C++ Yes Or No Questions
P: 8
Hi, i have a bit of a problem here.
I have an assignment to do an animal guessing game using an original database and updating it as the user enters new animals in it. The program enters the file data into an array of structures, with the animal and question in the same variable(question) and the bool isAnimal tells me whether its an animal or a question. If its a question it is followed by two numbers; one for the position of the line to go to if the user enters 'no' and another for 'yes'. The program works fine until the user inputs 'no' for a new animal(updated animal) after he enters yes for a new question(that he entered the last time to differentiate between animals). Here is the code, and sorry if the variable names are bad. Im using windows xp and visual c++ 2005.
  1. *snipped by Moderator*
  2. if(answer1 'yes')
  3. cout<<' I WIN!!!'<<endl << endl;
  4. else
  5. if(answer1 'no')
  6. {
  7. cout << ' I give up, what were you thinking of?' <<endl;
  8. cin >> game[x].question;
  9. game[x].isAnimal = true;
  10. x++;
  11. cout<< 'Please type a question that has a yes answer for '<< game[x - 1].question
  12. << endl << ' and a no answer for ' << game[game[c].no].question << ' (without a question mark):' << endl;
  13. cin.ignore();
  14. getline(cin, game[x].question);
  15. game[x].isAnimal = false;
  16. game[x].no = game[c].no;
  17. game[x].yes = x - 1 ;
  18. game[c].no = x;
  19. x++;
  20. }
  21. *snipped by Moderator*

So I'm looking to create a function that prompts the user to enter 'Y' for 'Yes restart the program' and 'N' for No, do not restart.

Dev C Yes Or No Question Questions

I know this should use the boolean operator, I'm just unsure as to how to implement it.

I also know to encase the body in a while loop ending in 'else if ('no')' for example.

I know this is completely wrong, but it's what I'm thinking could work:

/jesse-cook-rain-mp3-free-download.html. and the while loop being something like:

Thanks a lot for all the help!

  • 4 Contributors
  • forum 6 Replies
  • 2,912 Views
  • 20 Hours Discussion Span
  • commentLatest Postby SyrneLatest Post

Recommended Answers

Dev C Yes Or No Question Game

Jun 04, 2009  I can't believe that it so hard (maybe just for me) to do this. (Hope this is the right place in this forum for this question). It's so easy in VB NET but when I use C#, I can't not make the If Statement with Yes/No question and catch it from user in order to perform some code line.

  1. Validating Yes/No answers in C. Ask Question Asked 2 years, 4 months ago. Active 2 years, 4 months ago. Viewed 10k times 23. 4 $begingroup$ I intend to accept all of the following answers. $begingroup$ Yes it does - which is kind of in keeping with the original question plus mixtures, such as yeS.
  2. Deep Yes/No Questions. April Carolina. Have you ever been left out by the people you love? No Log in or sign up.

Dev C++ Yes Or No Questions

Your trying to compare letters, not numbers.
[CODE]int select;//should be char or string[/CODE]

[CODE]if(select.equals('Y'))
{//return a value}
if(no)
{//return a value}[/CODE]

Jump to Post

All 6 Replies