#include <iostream>
#include <cstdlib>
#include <cmath>
#include <ctime>
using namespace std;
int main()
{
srand(time(0));
int randNum = rand() % 100 + 1; // Generates random number between 1 and 100
int num = 0;
int name;//Name of player
cout << "Welcome to the Random Number Guessing Game!!"<<endl; // Name of Game.
cout<<"Your name is?"<<endl;//Request name of player.
do
{
// Loops until user finds the number
cout << "Enter your choice on the keyboard (#1-100): ";
cin >> num; // User's input of guessed number
if (num < randNum) // If num is < than the random number, inform player to try again.
cout <<"Your number was too low\n\n";
if (num > randNum) // If num is > than the random number, inform player to try again.
cout<<"Your number was too high\n\n";
} while (num != randNum); // Informs player if their number is correct.
cout<<"Excellent Job!! Your number is correct!!";
return 0;
}
----------------------------------------------------------------------------------
The program compiles ok-but i have a few bugs-
First-How do I get the program to request for a player's name (which will require input by player) and allow the name to be used throughout the game?
Second-How can I keep track of the user's guesses with a counter?
Third-I'm suppose to enter a score at the end of the program when the guess is right? So pretty much I'll need a tally i.e. The amount of ""Your number was too low" vs "Your number was too high".