English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

then attempts to guess the number. The program should make an inital guess of 50. THe program should then ask the user if 50 is the number the user has in mind, or if 50 is too high or too low. Based on the respone given by the user, the program should make another guess. Your program must continue to guess until the correct number is reached.

2006-11-16 06:31:52 · 5 answers · asked by Anonymous in Computers & Internet Programming & Design

Its in C++ Language duh!!!!

2006-11-16 06:44:42 · update #1

5 answers

Search for 'Binary Search' on the internet and you can pieces of sample code and algorithms. I'd say, use the algorithm to understand the logic and then code it yourself.

2006-11-16 06:51:41 · answer #1 · answered by SmartSpider 4 · 0 2

This guessing the type software question gets asked right here on Yahoo each and every of the time. I see it once or twice a week, actual. Do a seek and examine back on previous solutions to this question.

2016-10-15 15:29:59 · answer #2 · answered by Anonymous · 0 0

// Number Guessing Game
// Applies the srand() function and loops.

#include
#include
#include

using namespace std;

int main()
{
srand(time(0));
int randomNumber = rand() % 50 + 1; // generates random number between 1 and 50
int guess = 0;

cout << "\tThe Number Guessing Game\n\n"; // Title of program.
do
{
cout << "Enter your guess (#1-50): ";
cin >> guess; // put variable into 'guess'

if (guess < randomNumber) // If guess is < than the random number, display
cout << "Your guess was too low\n\n";

if (guess > randomNumber) // If guess is > than the random number, display
cout << "Your guess was too high\n\n";

} while (guess != randomNumber); // While guess is not equal to the random number

cout << "\nCongratulations! You've guessed the number.\n\n";
system("pause");

return 0;
}

2006-11-16 06:55:27 · answer #3 · answered by Farnsworth 3 · 1 1

Even if you get someone on here willing you cheat on your homework for you, they can't do a thing but guess unless you mention in which language you want the program written...

2006-11-16 06:36:46 · answer #4 · answered by anything_but_this_again 2 · 0 2

Sorry I can't help you. Give you a hint. Binary search Try yourself.

2006-11-16 06:34:39 · answer #5 · answered by jetkidz 3 · 1 1

fedest.com, questions and answers