# K1u's Guessing Game

## Recommended Posts

Coded for competition - http://k0h.org/portal/index.php?option=com...mp;topic=1792.0

```#include &lt;cstdlib&gt;
#include &lt;iostream&gt;

/*
K1u's Guessing Game.
Author: K1u.
Site: k0h.org.
Description: Defines a random number that the user must attempt to guess.
Disclaimer: I am not responsible for any damages this program my create.
I am not responsible for how you use this program.
*/

using namespace std;

int numGuesses = 3; /* Define the number of guesses. */

void game(void)
{
/*
Declaration of variables.
*/
int guessedNum; /* Guessed Number. The number you input. */
string choice; /* Choice for playing again. */

cout &lt;&lt; "What is the random number?n" &lt;&lt; "It is a number from 1 to 5!n";
cin &gt;&gt; guessedNum;

/* If the number is less or equal to 5 and greater 0
the program will proceed. */
if (guessedNum &lt;= 5 &amp;&amp; guessedNum &gt; 0)
{
/* Seeding of the Random Number Generator. */
srand(time(NULL));
int rnum = rand() % 5 + 1;

if (guessedNum == rnum)
{
cout &lt;&lt; "Correct!n";
}

else if (guessedNum != rnum)
{
/* If the number guessed is not correct then decrease the
number of guesses. */
numGuesses--;
cout &lt;&lt; "Incorrect!n";
cout &lt;&lt; "You only have " &lt;&lt; numGuesses &lt;&lt; " more guesses left!n";

/* If the number of guesses the user has made is less or equal to 0
then game over. */
if (numGuesses &lt;= 0)
{
cout &lt;&lt; "Bye!n";
}

else
{
game();
}
}
}

/* If the number is greater than 5 and less than 0. */
else
{
cout &lt;&lt; "Number must be between 1 and 5.n";
cout &lt;&lt; "Wish to play again?n" &lt;&lt; "Yes or Non";

cin &gt;&gt; choice;

if (choice == "Yes")
{
game();
}

else
{
cout &lt;&lt; "Bye!n";
}
}
}

int main(void)
{
/* We call upon the function game. */
game();
system("pause");
return 0;
}```

##### Share on other sites

Funny how your posting an entry of a compitition of which the runner of it is banned.

##### Share on other sites

first you ban him then you steal his game?!

n00b!

MSN != forums that's an abuse of power

##### Share on other sites

If only I was allowed to do that...

##### Share on other sites

K1u unblock me so i can keep announce the winner and get the game rolling again.

##### Share on other sites

K1u unblock me so i can keep announce the winner and get the game rolling again.

Fine... sorry I got mad at you... I will unban when I get home.

##### Share on other sites

I was at school, bored so i did it on my TI-83 PLus calculator

Ti-83 Plus Code:

```goto 0
.:By Sablefoxx:.:
Lbl 0
ClrHome
DelVar X
DelVar Y
randInt(1,100)-&gt;X
Disp "I am thinking"
Disp " of a Number"
Disp "Between"
input "1 and 100: ", Y
goto 5
Lbl 5
If Y=X
goto 1
If Y&gt;X
goto 2
If Y&lt;X
goto 3
Lbl 1
ClrHome
Disp "You Win it Was", X
pause
goto 0
Lbl 2
Clr Home
Disp "You Are Wrong"
Disp "It is Lower then", Y
pause
goto 4
Lbl 3
ClrHome
Disp "Wrong! Guess"
Disp "Higher then", Y
pause
goto 4
Lbl 4
ClrHome
DelVar Y
input "Guess Again: ", Y
goto 5```

NOTE: to get the '->' on line 5 use the 'STO->' key above 'ON'

and you do not type out commands you must choose them from a menu, most can found in the CATALOG

To make it start calc press PRGM then Press the '-->' until "new" is highlighted press ENTER, press [TAN] [5] [sIN] [LN] [LN] to name it "GUESS" type in code above if you cannot find a certain command try pressing '2nd' then 0 to bring up the CATALOG with just about every Ti-83 command in it.  To Run it goto your home (press 2nd [MODE]) press [PRGM] and select "GUESS" from the menu.  Good Luck!

Enjoy and happy slacking!

##### Share on other sites

I was at school, bored so i did it on my TI-83 PLus calculator

Ti-83 Plus Code:

```goto 0
.:By Sablefoxx:.:
Lbl 0
ClrHome
DelVar X
DelVar Y
randInt(1,100)-&gt;X
Disp "I am thinking"
Disp " of a Number"
Disp "Between"
input "1 and 100: ", Y
goto 5
Lbl 5
If Y=X
goto 1
If Y&gt;X
goto 2
If Y&lt;X
goto 3
Lbl 1
ClrHome
Disp "You Win it Was", X
pause
goto 0
Lbl 2
Clr Home
Disp "You Are Wrong"
Disp "It is Lower then", Y
pause
goto 4
Lbl 3
ClrHome
Disp "Wrong! Guess"
Disp "Higher then", Y
pause
goto 4
Lbl 4
ClrHome
DelVar Y
input "Guess Again: ", Y
goto 5```

NOTE: to get the '->' on line 5 use the 'STO->' key above 'ON'

and you do not type out commands you must choose them from a menu, most can found in the CATALOG

To make it start calc press PRGM then Press the '-->' until "new" is highlighted press ENTER, press [TAN] [5] [sIN] [LN] [LN] to name it "GUESS" type in code above if you cannot find a certain command try pressing '2nd' then 0 to bring up the CATALOG with just about every Ti-83 command in it.  To Run it goto your home (press 2nd [MODE]) press [PRGM] and select "GUESS" from the menu.  Good Luck!

Enjoy and happy slacking!

cool

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×