Hi there, I need to create a program that generates a random number, and asks the user to guess the number and the program tells them higher or lower, and if the program tells them higher, and they enter a number lower, or vice-versa, you call them a moron. For example,
Random number= 34
User enters- 17
Program says- higher
User enters- 10
Program says- moron higher
You must count the total number of guesses, and the number of time they were called moron.
I need help with the Moron counter, Thanks.
#include <iostream>
#include <time.h>
using namespace std;
int main ()
{
int nGuess,nNum,nCount=0;
srand((unsigned)time(0));
nGuess=rand ()%50+1;
while (nNum!=nGuess)
{
cout<<"Please enter a number between 1-50"<<endl;
cin>>nNum;
if (nNum==nGuess)
{
cout<<"Correct"<<endl;
nCount+=1;
}
else if (nNum>nGuess)
{
cout<<"Lower"<<endl;
nCount+=1;
}
else if (nNum<nGuess)
{
cout<<"Higher"<<endl;
nCount+=1;
}
}
cout<<"Total gueses equal "<<nCount<<endl;
//cout<<"Total Moron's equal "<<MoronCount<<endl;
return 0;
}