Guess Number Game

Posts 1–15 of 15 · Page 1 of 1
Guess Number Game
Code:
#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;

int main(int argc, char** argv)
{
        system("TITLE Guess My Number.");
        system("COLOR 5");

	srand(static_cast<unsigned int>(time(0)));

	int iMyNumber;
	int iYourNumber;
	int iPoints = 5;
      
	while(true)
	{
		cin.clear();
		iMyNumber = rand() % 100 + 1;
		
		cout << "You start with 5 points, each spin cost 1 point." << endl; 
		cout << "Guess my Number '1 - 100'" << endl;
		cout << "Get as many points as you can!" << endl;
		do
		{
			cout << "Enter your Number ";
			cin >> iYourNumber;
            iPoints += -1;
			if (iYourNumber > iMyNumber)
				cout << "Too high!" << endl << endl;
			else if (iYourNumber < iMyNumber)
				cout << "Too low!" << endl << endl;
		} while (iYourNumber != iMyNumber);
		cout << "Correct!" << endl << endl;
		cout << "You've got " << iPoints << " points." << endl << endl;
		cin.get();
	}
	return 0;
}
Did you ever got a correct answer with this ?
Quote Originally Posted by Hassan View Post
Did you ever got a correct answer with this ?
Yes, I've played it multiple times.
Like this ?





Edit:


You've got -2 points. lolwut?
Quote Originally Posted by Hassan View Post
Like this ?





Edit:


You've got -2 points. lolwut?
Genius -.-

I made my hint a little more complicated The hint points to a pointer which points to a struct whose third field points to a pointer which points to the value. GLHF

EDIT

@master131, hey genius when you get a wrong answer you lose a point, not gain one. Derp.
@Hassan lol he forgot to give you points when you get a correct answer
Code:
iPoints += -1; //Should be iPoints++;
lol, fail. Positive and negative = negative.
Quote Originally Posted by master131
lol, what I supposed to write was this:
iPoints--; not iPoints++;
Bullshit.

Quote Originally Posted by master131 View Post
Code:
iPoints += -1; //Should be iPoints++;

lol, fail. Positive and negative = negative.
Yes, "fail" that he got it right
Quote Originally Posted by Jason View Post


Bullshit.



Yes, "fail" that he got it right
Same as Java, in that aspect.
I'm new to C++, thanks though -.-..
Quote Originally Posted by Aggorance View Post
I'm new to C++, thanks though -.-..
Obviously, and don't mind. We're just having a little fun *apparently* ^^
lol, what I supposed to write was this:
iPoints--; not iPoints++;

Although what the OP wrote is still OK it's not good practice.
Same as all C-style syntax languages
alternatives to
Code:
var += -1
or var += 1
Code:
var++
var--
++var
--var
hahahaha i had to do this project for my programming class...it was simple and fun
Posts 1–15 of 15 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us