- Code: Select all
#include "stdafx.h"
#include <iostream>
using namespace std;
void loser()
{
cout << "Aw, you didn't win this time, but the number is still the same so you can try\nagain.";
}
void winner()
{
cout << "Congradulations, you have won my first game!";
}
int main()
{
int theNumber = 67;
int playerGuess;
cout << "Let's play guess my number. You have 5 tries.\n";
cout << "Type a number between 0 - 100: ";
for(int Tries = 0; Tries < 5; Tries++)
{
cin >> playerGuess;
if (playerGuess == theNumber)
cout << "YOU WIN!\n\n";
else
if (playerGuess > 100)
cout << "Stay within the boundries.\n";
else
if (playerGuess > theNumber)
cout << "Lower.\n";
else
if (playerGuess < 0)
cout << "No negative numbers!\n";
else
if (playerGuess < theNumber)
cout << "Higher.\n";
}
if(playerGuess == theNumber)
winner();
else
loser();
char f;
cin >> f;
return(0);
}
