when i try to build the solution for this program i get 4 warnings. they are:
c:\documents and settings\mike\my documents\visual studio 2005\projects\practice\practice\practice.cpp(22) : warning C4244: '=' : conversion from 'time_t' to 'int', possible loss of data
c:\documents and settings\mike\my documents\visual studio 2005\projects\practice\practice\practice.cpp(13) : warning C4101: 'ncount' : unreferenced local variable
c:\documents and settings\mike\my documents\visual studio 2005\projects\practice\practice\practice.cpp(19) : warning C4700: uninitialized local variable 'noOfguesses' used
c:\documents and settings\mike\my documents\visual studio 2005\projects\practice\practice\practice.cpp(20) : warning C4700: uninitialized local variable 'noofgamesplayed' used
and then it doesn't work. it gives me a message that says the variable 'noofguesses' is being used without being defined. could someone please show me what i need to do to fix this. here is my program. i will try to do it the right way this time
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main ()
{
int num;
int guess;
bool done;
int noOfGuesses = 0;
int ncount;
int sum=0;
int noOfguesses;
int avgNoOfGuesses;
int noofgamesplayed;
sum+=noOfguesses;
avgNoOfGuesses=sum/noofgamesplayed;
num = (rand() + time(0)) % 1000;
done = false;
while ((noOfGuesses < 10) && (!done))
{
cout << "Enter an integer greater"
<< " than or equal to 0 and "
<< "less than 1000: ";
cin >> guess;
cout << endl;
noOfGuesses++;
if (guess == num)
{
cout << "you guessed the correct "
<< "number." << endl;
done = true;
}
else
if (guess < num)
cout << "Your guess is lower "
<< "than the number. \n"
<< "Guess again!" << endl;
else
cout << "Your guess is higher "
<< "than the number.\n"
<< "guess again!" << endl;
cout <<"Total gueses equal " << noOfGuesses << endl;
}
return 0;
}
i hope i did it right this time. if i didn't i am sorry