I have this problem where there are two people. The first person has to enter a secret number. Then the screen has to be cleared and then a second person has 5 guesses to guess the secret number! I just cannot figure out what I am doing wrong. Can someone please help?
#include <iostream>
using namespace std;
using namespace cstdlib;
int SecretNumber; //first persons number
int Count; //number of guesses
int Guess; //actual guessed number of second person
int main()
{
cout <<"Enter a secret number: "<<
cin >> SecretNumber;
system("CLS");
int Count;
for (Count = 1; Count <= 5; Count++)
{
cout <<"Guess the secret number: "<< endl;
cin >> Guess;
Also.. int Count is declared as a global variable AND a local variable. This shouldn't make a difference but it's bad programming. Looking at that code though, NONE of those really should be global and it's best to never use a global variable unless it's 100% necessary (which really should be never.)
Yeah I know its not good but Im trying to get it. I've only been programming for a couple of months and it is an online class. My professor isn't helping me at all, he just tells me to look at the pseudocode and that doesn't help at all when it comes to actually using the c++ language. I will do the changes and see how it does. Thank you so much for the help!
I was wondering if you might be able to help me with one last thing. What would I add to my code in order to make it display "you lose" after 5 guesses instead of it saying "try again" still?
here is my changed code.
int main()
{
int SecretNumber;
int Guess;
cout <<"Enter a secret number: ";
cin >> SecretNumber;
system("CLS");
int Count;
for (Count = 1; Count <= 5; Count++)
{
cout <<"Guess the secret number: "<< endl;
cin >> Guess;