Here’s how I solved the challenge: I pretty much applied the same solution to the previous challenge, where I declared WORD_LENGTH inside it’s own method and returned the variable. I split up the get_guess_and_play_back method into get_guess and play_back methods, which was pretty easy. The struggle, though was figuring out which part of the output I had to loop. Ultimately I decided on looping play_back since get_guess was called in the method anyway. The final complication was removing the get_guess method call in the main method, since it was causing my code to ask for input 6 times instead of WORD_LENGTH times. :slight_smile:

Here’s my code! It works well to my knowledge:

using namespace std;

void print_intro();
string get_guess();
void print_back();

int main() {



return 0;


//declaring word_length
int word_length() {
constexpr int WORD_LENGTH = 5;

//introducing the game

void print_intro(){

cout << "Welcome to the Bulls and Cows game!" << endl << endl;
cout << "In this game you will be required to guess an isogram that is " << word_length();
cout << " characters in length; however, you will only be alloted a limited number of ";
cout << "letter or word guesses, so chose wisely. Goodluck! I hope you have fun! :)";
cout << endl << endl;

//getting a guess from the player

cout << "Again, the word length is " << word_length() << " What is your first letter or ";
cout << "word guess?\n\n";



//get guess

string get_guess() {
string Guess = “”;

cout << "Enter your guess: ";
	getline(cin, Guess);

return Guess;


//print guess back to them
void print_back() {
for (int count = 1; count <= word_length(); count++) {
cout << “\nOkay, so your first guess was " “’” << get_guess() << “’”;
cout << " right ?\nLet’s see if we have a match.”;
cout << “\n\n. . .\n\n”;

1 Like

Thanks for sharing