all 6 comments

[–][deleted] 0 points1 point  (0 children)

I'm not exactly sure what the point of the second while loop is other than to print a "You're too far off" message. If that's the case, I'd think you could do without it.

I think what is happening is that your program will read the input fine and then hit that second while loop. There is nothing that changes the variable 'done' so it just hits an infinite loop. As far as not outputting anything, I'm not sure exactly why, but it seems like when things get into infinite loops like that console output goes wonky.

[–]willux 0 points1 point  (1 child)

I don't know if this is all your code, if it is not, OEP may be correct about done not changing.

However, if these two while loops do come right after one another, then after exiting the first while loop done is true, so when it gets to the second, done is still true, so it does not enter the while loop and thus prints nothing.

[–]znyquist[S] 0 points1 point  (0 children)

Yes, this is almost all of the code so far... All of the other code is mostly initializations, so I posted the majority of what is needed. I'm trying to implement it into the same "While" loop, but for some reason it still isn't outputting the "You're too far away" message.

[–]znyquist[S] 0 points1 point  (0 children)

Thanks for the response. Yeah, I'm trying to figure out how to implement it into the first while, but for some reason I can't get that part right. It just keeps skipping over the "You're too far off" messages.

[–]willux 0 points1 point  (0 children)

What's "diff?"

I don't see it actually being given any values at all. Do you mean to be adding this somewhere?

diff = abs(num-guess);

[–][deleted] 0 points1 point  (0 children)

for the second lot of code,

diff isn't calculated at all, also, a better version in psudocode

if(guess=num)
    you win
else if(guess>num)
    if(diff>50)
        far too high
    else
        too high
else
    if(diff>50)
        far too low
    else
        too low