The game plays fine, but I need help figuring out a code to keep the points from ever going below 0 no matter how many guesses are input.
#include <iostream>
#include <ctime>
using namespace std;
const int LOW = 1; //lowest number that can be guessed
const int HIGH = 10; //highest number that can be guessed
void main( )
{
srand(unsigned int(time(NULL))); //Starts random num gen
int guess; // the number the user inputs
int num = rand() % (HIGH - LOW + 1) + LOW; // random within the parameters
cout<< "Please input a number Between 1 and 10" <<"\n";
cin>> guess;
int points = 5; //the points given for each game
do
{
if (guess == num)
{
cout<< "Correct you guessed right" << "\n";
}
else if (guess > num)
{
cout<< "Too High" << "\n";
points --;
cout<< "Your total points are" << "\n";
cout<< points << "\n";
cout<< "Please enter another number" << "\n";
cin>> guess;
}
else if (guess < num)
{
cout<< "Too Low" << "\n";
points --;
cout<< "Your total points are" << "\n";
cout<< points << "\n";
cout<< "Please enter another number" << "\n";
cin>> guess;
}
}while (guess!= num);
cout<< "Your Guess was" << "\n";
cout<< guess << "\n";
cout<< "The number to guess was" << "\n";
cout<< num << "\n";
cout<< "Your total points are" << "\n";
cout<< points << "\n";