I need to create a guessing number program that notifies the user whether or not they're guess is higher or lower to the random number created by the program. My problem is that the program only recognizes that the guess the user makes is lower than the random number. If someone could tell me how I can get the program to recognize if the guess is higher than the random number that would be great. thanks
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main()
{
int num, guess, diff;
bool done;
num = (rand() + time(0)) % 100;
done=false;
while (!done)
{
cout<<"Enter an integer greater than or equal to 0 and"
<<" less than 100"<<endl;
cin>>guess;
cout<<endl;
diff = num - guess;
if (diff<0)
{
diff==diff*-1;
}
if(diff==0)
{
cout<<"You guessed the correct number"<<endl;
done=true;
}
if (diff>=50)
{
if(guess>num)
{
cout<<"Your guess is very high guess again"<<endl;
}
else
{
cout<<"Your guess is very low guess again"<<endl;
}
}
else if (diff>=30 && diff<50)
{
if(guess>num)
{
cout<<"Your guess is high guess again"<<endl;
}
else
{
cout<<"Your guess is low guess again"<<endl;
}
}
else if (diff>=15 && diff<30)
{
if (guess>num)
{
cout<<"Your guess is a little high, guess again"<<endl;
}
else
{
cout<<"Your guess is a little low, guess again"<<endl;
}
}
else if (diff>0 && diff<15)
{
if(guess>num)
{
cout<<"Your guess is really close, but high. guess again"<<endl;
}
else
{
cout<<"Your guess is really close, but low, guess again"<<endl;
}
}
}
return 0;
}