Another For Loop

#include <iostream>
#include <string>
using namespace std;

//Function Prototypes
void PrintIntro();
string GetGuessAndPrintBack();

//Entry point for our application
int main()
{
	PrintIntro();

	constexpr int MAX_GUESS=5;
	for (int GuessCount = 1; GuessCount <= MAX_GUESS; GuessCount++)
	{
		GetGuessAndPrintBack();
	}
	return 0;
}
//introduce the game
void PrintIntro()
{
	constexpr int WORD_LENGTH = 5;

	cout << "Welcome to Bulls and Cows, a fun word game.\n";
	cout << "Can you guess the " << WORD_LENGTH;
	cout << " letter isogram I'm thinking of?\n";
	return;
}
//get guess from the player
string GetGuessAndPrintBack()
{
	string Guess = "";
	cout << "What is your guess? "; 
	getline(cin, Guess);
	//repeat the guess back to them
	cout << "You guessed " << Guess << endl;
	return Guess;

}

Not sure why the indents mess up in the code tag, but they are there in the code

Thanks for sharing, and well done using the [code] tag to make it look so pretty.

Privacy & Terms