# Thread: Making a random number guessing game (exit failure? wtf)

1. Originally Posted by muffinman8641
What does !guess do? I know != is not equal to, so something related to that?

It's like reverse psychology! You're a wizard!
/thanks
! is logical NOT. Ie, it makes true false and false true.
!true = false
!false = true
if (10 != 20) means if 10 is not equal to 20
if (!(10 == 20) means if NOT 10 is equal to 20

Originally Posted by muffinman8641
I have no idea what to do with this.
What about the if ((atry > compguess) || (atry < 1)) { section?
Sorry for being annoying, I'm just a little confused.
Same here. We play a logical game.
State the events that happens in the whole process when asking for user input.
Ie, ask for input, if guessed > real ...
This isn't difficult. Then you can easily translate that logic into code.
Give it a try and reply if you have problems.

2. to do the hint thing you have to use mod or divide
here is how to get places except ones:
Code:
```placenumber = 10 // it can be 10 to any power but i will just use ten here
cout << "the " << placenumber << "/'s place is " << compnumber % placenumber << endl;```
to get the ones is a bit harder (might be a better way to do this)
Code:
```int temp = compnumber;
while(temp < 10;
temp -= 10;
cout << "the ones place is " << temp << endl;```

3. Originally Posted by bobknows
to do the hint thing you have to use mod or divide
here is how to get places except ones:
Code:
```placenumber = 10 // it can be 10 to any power but i will just use ten here
cout << "the " << placenumber << "/'s place is " << compnumber % placenumber << endl;```
to get the ones is a bit harder (might be a better way to do this)
Code:
```int temp = compnumber;
while(temp < 10;
temp -= 10;
cout << "the ones place is " << temp << endl;```
My compiler says that the placenumber function is unrecognized. What header?

4. sorry, placenumber should be:
Code:
`int placenumber = 10;`
placenumber is used for the mod to take the excess off the left side of the number.

here is a function to do everything you need. i found this at this link. all credit goes to the poster
Code:
```char nthdigit(int x, int n)
{
while (n--) {
x /= 10;
}
return (x % 10) + '0';
}```
the previous snippets i wrote were written fast and sloppily, just to give you an idea

5. Geez. Don't hand out solution to problems!
If I wanted to do, I could have done so. The reason I didn't is because I wanted muffinman8641 to learn how to do on his/her own. An exercise, if you will. You learn much more that way.

6. Once someone hands me the answer, I can practice it and learn it so I'll learn it.
It doesn't have to be a riddle. :P
(btw I'm a he, as indicated by muffinman8641)

[Edit- as a matter of fact, the int placenumber=10 statement returns the ones place (not sure why).]

7. Originally Posted by muffinman8641
Once someone hands me the answer, I can practice it and learn it so I'll learn it.
It doesn't have to be a riddle. :P
Unfortunately, you a minority in that.

(btw I'm a he, as indicated by muffinman8641)
The internet is an anonymous place. One cannot be sure of anyone's gender from a username alone. I rather not call someone by gender unless that someone declares it publically.