I'm trying to create a random number between 1 and 100, but it keeps coming up with the number 42. I've tried everything to try and fix it but nothing will work.
I have tried various "#include" statements that I have found in examples, but still none of them work.Code:#include <iostream> #include <stdlib.h> using namespace std; int number; int guess; int correct = 0; int main() { number = (rand()%100) + 1; do { cout << "Enter your guess at the number"; cin >> guess; if (guess < number) { cout << "Your guess is to low" << endl; }; if (guess > number) { cout << "Your guess is to high" << endl; }; if (guess == number || guess == 0) { cout << endl << "Well done your guess is correct!"; correct ++; }; }while (correct < 1); return 0; }
Anyone help?
Thanks