Hello,
I have been scouring the forums and have not found a solution to my problem. OK here it is. I am a beginner about 5 weeks into first term Programming Logic and Design class where we use flowcharts and psudocode as the way my school teaches the basics of programming. Anyway I am trying to code our final project for fun.
I am making an Animal guessing game that only has one animal to guess. The problem I am having is getting my program to step to the next segment in my array. All that my loop does is repeat the first question over and over and it doesn't step to the next question in the array. I am just looking for a point in the right direction so I can get this figured out and finish this program.
#include <iostream>
#include <string>
usingnamespace std;
int main()
{
string animalGuess;
string animalAnswer = "Aardvark";
string animalQuestions [5];
animalQuestions [0] = "The animal I am thinking of has fur. What is it?";
animalQuestions [1] = "The animal I am thinking of eats ants. What is it?";
animalQuestions [2] = "The animal I am thinking of lives in Africa. What is it?";
animalQuestions [3] = "The animal I am thinking of has sharp claws. What is it?";
animalQuestions [4] = "The animal I am thinking of has a long tounge. What is it?";
cout << "Welcome to a simple one animal guessing game." << endl;
for (int m = 0; m < 5; ++m)
{
if (animalGuess != animalAnswer)
{
cout << animalQuestions [0] << endl;
cin >> animalGuess;
}
}
return 0;
}
Thank you so much. I have been going over this all weekend. I did not finish the rest of the program because I wanted to get this part working before moving on. Again thank you for you answer. It had helped me greatly.