OK I am new to C++ so I decided I'd toy around with what I know and try and do some neat stuff. I'm trying to make a program that will try and make you guess the number it's thinking of. But every time I run the program it always thinks of 41. I don't know the rand() function I'm trying to use so if you could explain it to me that would be nice. Here is the code:
#include <iostream>
using namespace std;
int main(){
int q;
int n;
//make the number the computer makes limitations. <=10 and >= 1.
n <=10;
n >=1;
n = random();
//prompt for q, the number the user guessed.
cout << "Please try and guess my random number!";
cin >> q;
if (q==n)
cout << "You have guessed correctly! what are the odds!";
else {
cout << "I'm sorry the correct number was: "<< n;
}
system ("pause");
return 0;
}