Guessing Number Game Problem
i tried writing a guess the number game using functions but i ran into some problems
Code:
8 C:\Documents and Settings\wmorrish\Desktop\New Folder\main.cpp ` guesscount' undeclared (first use this function)
Code:
10 C:\Documents and Settings\wmorrish\Desktop\New Folder\main.cpp ` guess' undeclared (first use this function)
would i have to redeclare guess and guesscount inside the function? or is there any other way around this?
here is my code so far
Code:
#include <ctime>
#include <cstdio>
using namespace std;
inline void guessagain()
{
cout<<"Guesses Left"<<guesscount<<endl;
cout<<"Guess:"<<endl;
cin >> guess;
guesscount = guesscount -1;
}
int main()
{
srand((unsigned)time(0))
int number = rand()%10;
int guess;
int guesscount;
cout<<"The Computer Has Thought Of A Number Try And Guess It"<<endl;
cout<<"you have 10 guesses."<<endl;
cout<<"Guess : ";
cin >> guess;
guesscount = guesscount - 1;
if(guess == number)
{
cout<<"Well Done!! You Guessed The Random Number "<<number<<" With "<<guesscount<<" Tries Left"<<endl;
}
else if(guess > number)
{
cout<<"To High, Try A Lower Number."<<endl;
guessagain();
}
else if(guess < number)
{
cout<<"To Low, Try A Higher Number"<<endl;
guessagain();
}
return 0;
}