// --------------------------------------------------------------
// highlowcd.cpp
// Game created for user to guess the number the computer picked
// using the high and low clues to narrow down the answer.
// Written by Janine Bouyssounouse 2/3/08
// Created with Bloodshed Dev C++
// --------------------------------------------------------------
#include <iostream>
#include <stdlib.h>
#include <cstdlib>
#include <ctime>
using namespace std;
void welcome();
int main(int argc, char *argv[])
{
srand(time(0));
int number = (1 + rand() % 100);
int guess = 0;
int numGuesses = 0;
welcome();
do
{
cout << "\nWhat is your guess? ";
cin >> guess;
numGuesses++;
if (guess > number)
cout << "\nToo high.";
if (guess < number)
cout << "\nToo low.";
} while (guess != number);
cout << "\n\nCongratulations! You guessed the number " << number
<< "." << "\nIt took you " << numGuesses << " guesses.\n" << endl;
system("PAUSE");
return 0;
}
// -------------------------------------------------------------
// welcomes the user to the game
void welcome()
{
cout << "\tWelcome to High Low!";
cout << "\n\nThe computer will guess a number and you will try to guess";
cout << "\nwhat it is. The computer will tell you if you are high or low";
cout << "\nand you can guess again until you get the answer.\n\n";
cout << "The number will be between 1 and 100.\n\n";
} // end welcome function