Basically you guess a number, if you guessed the number correctly then a message will pop up saying you guessed right, and if not wrong...however im trying to make it so that if you guess to high or too low, it tells you to guess the opposite (lower or higher and vice versa).
Here's the code I have so far, there's errors on it obviously because it's not done haha:
#include "stdafx.h"
#include <iostream>
#include <Windows.h>
using namespace std;
int main()
{
int theNumber = 76;
int playersGuess;
cout << "Hello and welcome! \n";
Sleep(3000);
cout << "Lets play guess my number! \n";
Sleep(3000);
cout << "Please enter a number between 0 and 100: ";
cin >> playersGuess; //cin >> is the extraction operator, it waits for the user to type something in
bool alive = true;
if ( playersGuess == theNumber )
{
cout << "They match... \n";
Sleep(2000);
cout << "Good job! \n";
}
else
if ( playersGuess > theNumber )
{
cout << "They don't match... \n";
Sleep(2000);
cout << "I'm sorry, your guess is too high. \n";
}
else
if ( playersGuess < theNumber )
{
cout << "They don't match... \n";
Sleep(3000);
cout << "I'm sorry, your guess is too low. \n";
}
else
char f;
cin >> f;
return 0;
}
So I guess my question is am I on the right track? what do I need to add or watch for? I'd like some help please
Edited by TkTech, 28 July 2010 - 08:55 PM.


Sign In
Create Account


Back to top









