Thank you for the tips guys i will try them out i just have to figure a way fo getting it to give the user 8 trys max. Thanks for not talking to clever for me lol :) This Better ******* Work!
bobski2200
Posts
-
C++ Random Question -
C++ Random Question:)First off apols if this is in the wrong section i am new here I have this code now and try as i may i cannot get the random number to change it is always 41 when it should be between 0-100. I am not that good at C++ and would appreciate any help can i please reinforce the basis that my knowledge is very basic thanks for any help guys. #include #include int main(void) { // declare our variables // Guess entered by user and random number int guess, random; random = rand(); // Creates a loop for the main program do { cout << "My High-Low game!\n\n"; cout << "Please enter a number between 0 and 100: "; cin >> guess; cout << "You entered " << guess << "!\n"; if (guess == random) { cout << "Correct guess, the answer is " << guess << "!\n"; } else { if (guess > random) { cout << "Your guess is too high!\n"; } else { cout << "Your guess is too low!\n"; } } // Terminating condition for the loop // Program stops when the guess equals the random number } while(guess!=random); // This command pauses the program system("PAUSE"); return 0; } This Better ******* Work!