My code i modified it to type wrong answer when Response not y/n

#include
#include
void intro(void);
void check(void);
std::string getguess();
bool playagain();

int main()
{
do {
//Print Program introduction
intro();
//Getting a Guess and iterations
int count;
for (count = 1; count <= 5; count++)
{
check();
}
} while (playagain() == true);
return 0;
}

void intro(void) {

constexpr int WORLD_LENGTH = 9;
std::cout << "Hello World" << std::endl;
std::cout << "Bull and Cow Game a funny Game";
std::cout << std::endl;
std::cout << "Can you guess the " << WORLD_LENGTH;
std::cout << " Letter Isogram I'm thinking of ?";
std::cout << std::endl;
return;

}

void check(void) {

std::string GUESS = "";
std::cout << std::endl;
std::cout << std::endl;
std::cout << "Your Guess was :" << getguess();
std::cout << std::endl;
std::cout << std::endl;
return;

}

std::string getguess() {
std::string Hello;
std::cout << “Enter Your Guess :”;
getline(std::cin, Hello);
return Hello;
}

bool playagain() {

Repeat:std::cout << "Would you Like To Play Again (y/n) ?";

std::cout << std::endl;
std::cout << std::endl;
std::string Response = "";

getline(std::cin, Response);

 if ((Response[0] == 'y') || (Response[0] == 'Y')) {
	return true;
}
else if ((Response[0] == 'n') || (Response[0] == 'N')) {
	return false;
}

	else {
		std::cout << " Wrong Answer";
		std::cout << std::endl;
		std::cout << std::endl;
		goto Repeat;
	}

	return  playagain();

}

Privacy & Terms