Heya. Here’s my attempt at the for loop challenge in lecture 21:
#include <iostream>
#include <string>
void PrintIntro();
std::string GetGuess();
void PrintGuess(std::string Guess);
// the entry point for the application
int main()
{
constexpr int MAX_TRIES = 5;
PrintIntro();
for (int i = 0; i < MAX_TRIES; i++)
{
PrintGuess(GetGuess());
}
return 0;
}
void PrintIntro()
{
// introduce the game
constexpr int WORD_LENGTH = 5;
std::cout << "Welcome to Bulls and Cows, a fun word game." << std::endl;
std::cout << "Can you guess the " << WORD_LENGTH;
std::cout << " letter isogram I'm thinking of?" << std::endl;
return;
}
std::string GetGuess()
{
// get a guess from the player
std::cout << "Enter your guess: ";
std::string Guess = "";
std::getline(std::cin, Guess);
return Guess;
}
void PrintGuess(std::string Guess)
{
// repeat the guess back to the player
std::cout << "You guessed " << Guess << std::endl;
return;
}

