Code:
Code:
#include<iostream>
#include <cstdlib>
using namespace std;
int main() {
int guess, secretnumber;
secretnumber = rand();
cout << "Guess the number: ";
cin >> secretnumber;
if (guess = secretnumber)
cout << "You guessed it!";
else if(guess > secretnumber)
cout << "You're to high!";
else if(guess < secretnumber)
cout << "You're to low!";
return 0;
}
When I run it, I guess it every time for some reason, and I don't think it is being random. Please tell me if this code is correct, I've been fooling around for a while, and my book I don't think is very current (not by years, but some things are off, for instance when I try the gets(); code to input a string into an array, the compiler just skips over it and goes to the next statement, I noticed that the cin function thingy stops the thing while until you type something in an hit enter, but gets() does not do this.