My for loop

I wasn’t sure where to put the new constexpr but I suppose anywhere before the loop works.

#include
#include

using namespace std;
void PrintIntro();
string GetGuessandPrint();

// Entry Point for Application
int main() {
constexpr int limit=5;
PrintIntro();
for (int count=1; count <= limit; count++){
GetGuessandPrint();
}
return 0;
}

// introduce the game
void PrintIntro() {
constexpr int WORD_LENGTH = 9;
cout << “Welcome to Bulls and Cows, a fun world game.\n”;
cout << “Can you guess the " << WORD_LENGTH;
cout << " letter isogram I’m thinking of?\n”;
return;
}

// get a guess from the player and print it back
string GetGuessandPrint() {
string Guess = “”;
cout << "\nPlease enter your guess: ";
getline(cin, Guess);
cout << "You entered: " << Guess << endl;
return Guess;
}

Privacy & Terms