Error in trying to compile a program of a guessing game

Say you pick a number, you are given ten attempts to guess it right
if you're right display CONGRATULATIONS!! and then end the program.
But if you finish the ten attempts and you still don't know the number,
The program should display "I give up!"

and only one thing I need help is trying to detect cheat.

how do you detect cheat when you come so close to knowing the number and then the other person keeps saying that its higher or lower than the number guesed
i really need you help

PLIZ CAN ANY1 HELP ME??
Last edited on
Do you mean that if the person is falsely saying "higher" when its actaully lower, just to put them off?
if not, then specify and alos tell me about the other person and how it works.
actually the person has to say Congratulations but then the person keeps saying that its lower. And that's where I have to say You cheat!

here this is an example of how it should look like

Select a number between 1 and 15.

Press any key to continue...

Alice's attempt 1: My guess for your number is 10.
Is your number higher (H), lower (L), or I win (W)?: H

Alice's attempt 2: My guess for your number is 15.
Is your number higher (H), lower (L), or I win (W)?: L

Alice's attempt 3: My guess for your number is 12.
Is your number higher (H), lower (L), or I win (W)?: L

Alice's attempt 4: My guess for your number is 11.
Is your number higher (H), lower (L), or I win (W)?: L

Alice says: You cheat!

Press any key to continue...
Last edited on
1
2
3
4
5
6
7
8
9
//THe character that they sayer higher or lower to: H, L, W will be char input.
char input;
cout <<"IS the munber higher lower or I win?: ";
cin>> input;
if (input == 'L' || input =='H' && aliceNumber == chosenNumber) 
{
cout << "You cheated"<<endl;
}

This if statement checks if either: first, if you input an 'L' or a 'H', using the logical operator '||' which is like an 'or' checker. so if you entered either h or l AND (&&) the number she guessed (aliceNumber) == the number ( chosenN umber) then she guessed correctly, but they entered 'l' or 'h', so it prints out "cheat"
Topic archived. No new replies allowed.