#include <iostream>
#include <string>
//#include <stdio.h>
using namespace std;
constexpr int WORD_LENGTH = 5;
void PrintIntro();
string GetGuess();
// the entry point for our application
int main()
{
PrintIntro();
int limit = 5; // the maximum number of guesses
for(int count = 1; count <= limit; count++)
{
cout << "This is your attempt number " << count << " . " << "Enter your guess \n";
cout << "Your guess is '" << GetGuess() << "' ?\n";
}
//std::cout << std::endl<< GetGuess();
return 0;
}
void PrintIntro() {
cout << "Welcome to Bulls and Cows\n";
cout << "Can you guess the " << WORD_LENGTH << " letter isogram I am thinking of?\n";
return;
}
string GetGuess() {
// get a guess from the player
string Guess = "";
getline(cin, Guess);
return Guess;
Any idea what magic number is? I am sure I have not missed any lessons!
Edited your post to use a code block. please do that in the future. And a magic number is anything with some meaning
Examples, if your code was instead:
for(int count = 1; count <= 5; count++)
///
cout << "Can you guess the " << 5<< " letter isogram I am thinking of?\n";
Here both 5’s are magic numbers. They have meaning but it’s up to the reader to figure that out in this instance. Obviously not that hard in this particular case but it could be much harder.
I have pondered this email for some time now and I cannot understand what you’re trying to tell me. Please give me examples of what to do and what not to do. Code block? Isn’t that what I have been using.?
I
Am I supposed to create a new topic everytime in discussion because that’s the only button I can see that is closely relevant?
What to do, what you have. What not to do, the code I posted. In the code I posted 5 is a “magic number”.
https://en.m.wikipedia.org/wiki/Magic_number_(programming)
You did not, to get a code block you need to indent by 4 spaces or surround the code with 3 backticks. Look at the edit history of your post for the difference.
You don’t have to but yes, that’s the idea.
Thanks
I will try and use three back ticks.
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.