Hello, I am a beginner in C++ and really need help finishing my code. My program asks the user to guess a number from 1 to 1000 and when the user guesses the number correctly, the user is asked if they want to play again, if so, then the program should ask the user to guess the number and so forth, but I have trouble keeping the program running if the user enters y(yes). I do not know what to do I have tried my best and would appreciate help. Also, the header file has all the include statements I need. Also, all my indentations are correct and I don't know why it does not show that when I submit my topic/question.
[#include "cisp400asgn4.h" //Includes what's in the header file
int main()
{
int num;
int guesses;
int tries = 0;
char y;
char n;
srand(time(0)); // Random number generator.
num = rand() % 1000 + 1; // Random number between 1 and 1000.
char response = 'y';
do
{
// generate number
//
// while( guess != number ) {
// get user's guess
// }
cout << "Play again? ";
cin >> response;
} while( response != 'n' );
Currently you're reading two char variables (y and n) which is not useful. what is currently happening is that the program will only exit if the 2nd char entered is a 'n'.