This is where I’ll put all my challenge results when the course prompts me to do so.
Here is the code I used for the forloop challenge
In this challenge he asks to have the player guess 5 times using a forloop.
#include <iostream>
#include <string>
using namespace std;
void PrintIntro();
string GetGuessAndPrint();
int main() {
PrintIntro();
//have the user guess a number of times
int numberOfGuesses = 5;
for(int i = 0; i < numberOfGuesses; i++) {
GetGuessAndPrint();
}
return 0;
}
void PrintIntro() {
//introduce the game
constexpr int WORD_LENGTH = 5;
cout << "In this game we guess a word isogram with " << WORD_LENGTH << " letters!";
return;
}
string GetGuessAndPrint() {
//get a guess from the player
string guess = "";
cout << endl << "Hey, Guess a word!\n";
getline(cin,guess);
//repeat their guess back to them
cout << "Your guess was " << guess;
return guess;
}