Number Guessing game (need Help)

Please HELP ME OUT. Below is the assignment by my teacher.It is due tomorrow. Please write me code for this or atlease psudo code. THANKS ,
This is a fairly straight forward assignment. It does not necessarily require pointers, and it certainly does not require dynamic memory allocation. But it is good practice for flow of control and general skills, and it is important to a future lesson we will do on Object Oriented Programming.
In this assignment you will write a program that can figure out a number that you are thinking of. The human user thinks of a number between 1 and 100. The program makes guesses, and the users tells the program to guess higher, or lower.
A sample run of the program might look like this:
Guess a number between 1 and 100. Press the enter key when you are ready.
Is it 50? (h/l/c): h
Is it 75? (h/l/c): h
Is it 87? (h/l/c): l
Is it 81? (h/l/c): c
Great! Do you want to play again? (y/n): y
Guess a number between 1 and 100. Press the enter key when you are ready.
Is it 50? (h/l/c): l
Is it 25? (h/l/c): h
Is it 37? (h/l/c): c
Great! Do you want to play again? (y/n): n
Notice that the user inputs the characters ‘h’, ‘l’, and ‘c’ for higher, lower, and correct, respectively.
Note that this particular program seems to implement the binary search. That is the recommended algorithm.
It is possible in a program like this for the user to give the program bad feedback. Feel free to implement any behavior that you want in that case.
Last edited on
You do realise that at no point have you asked any sort of question, or said at all what the problem is? All I have learnt from this post, is that someone, somewhere in the world, is learning C++.

Meerkat
I donot know how to do this assignment. This is due tomorrow but At this point my mind isnt working . Can you write me code for this ??? Will appreciate that ... Thanks
Haha, that is optimistic of you. Here's the slightest nudge in vaguely the right direction:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>

using namespace std;

int main()
{
	//variables here
	cout << "Think of a number between 1 and 100" << endl;
	
	while(condition here){
		//program chooses random number
		cout << "Is your number: " << random_number << endl;
		//read in the number
		if(condition){
			//do whatever, prob need if else statments as well
		}
	}
}


Meerkat
After seeing so many "please do my homework for me" posts -- it's refreshing to see the honesty of someone come out and outright saying that is what they're looking for.

Still, though, this isn't a homework service. We're not going to do your work for you.
@TheMeerkat: Thanks :)
Do you think that's going to help the situation? (I don't think Disch deserved that)



Haha, he must of had a bad day sometime between thanking me 2 days ago, and posting that today.
Shoop-Da-Whoop 'tis gone.
Topic archived. No new replies allowed.