I'm stuck on the problem of trying to make my code loop back around after a condition.
I'm asking player 1 to enter a number between 0 and 99, if they enter anything outside of that the code should ask them to retry this. The problem is I honestly have no idea how to enable that from my code. This is what I have so far, I don't understand how to throw a while loop in here to have it circle back:
int secretnumber;
int guesses;
printf("Player 1: Type a number between 0 and 99 and press return:\n");
scanf("%d",&secretnumber);
if (secretnumber > 99 || secretnumber < 0)
printf("Secret number cannot be greater than 99 or below 0.");
else
printf("Type the number of guesses that player 2 gets and press return: \n");
scanf("%d",&guesses);
I'm new to this and fully aware of how incompetent I probably sound, so I apologize in advance for that.
Aucun commentaire:
Enregistrer un commentaire