question loops

i need to use a loop but i am not sure exactly how. here is the senerio.

i give a clue and the user has to guess the answer. if they get it wrong i give another clue and they guess the answer. this goes on for 5 different clues. it needs to keep a count of the tries. my problem is how to do it with giving the clue at the end of each unsuccessful try. the clues are comming out of a string array
Try looking at examples of how loops work here:
http://www.cplusplus.com/doc/tutorial/control/
closed account (Lv0f92yv)
I would use a for loop and an array of clues (probably char*s?). Something like

for as many clues as the user can possibly get
update the number of tries
show the user the nth clue
get the user's answer and determine if it is correct
if correct
tell the user how many tries it took (or something)
break out of the loop so we finish...

otherwise, the loop continues until all clues have been given. There are probably easier ways to do this, but that's just one example.

Alternatively:

while the user isn't correct and we've given less than 5 clues
update the number of tries
give the user the nth clue
get input
if user is right
set a bool to the check fails and loop ends
tell the user how many tries it took (or something)
else
increase 'n' so we show the next clue or break out of the loop if n > 5

This site has good tutorials on loops if you aren't familiar with the code. Hope this helps.

First make an 2 dimensional array of chars and write in your hints.

then make a for loop sort of like this:

for(int n=0;n<5;n++)

and then set it to output
the nth string in the array.
Topic archived. No new replies allowed.