1. ## help improving code

the random number is always 41

Code:
```//*last edited 5/27/2009
number guessing game
By CJ*/
#include <iostream>
#include <cstdlib>

using namespace std;

int main()
{
int a;//to declare a a random number
a = rand();
int x;// used to compare to a

cout<<"welcome to the number guessing game\n";

if ( a < 50 ) { //gives you details about what the number (a) is
cout<<"the number is less than 50\n";
}
if ( a > 50 ) {
cout<<"the number is greater than fifty\n";
}
if ( a == 50 ) {
cout<<"the number is fifty\n";
}
if ( a > 0 ) {
cout<<"the number is greater than 0\n";
}

while ( x != a ) {

cout<<"What do you think the number is?\n";//gives x which is compared to a
cin>> x;
cin.ignore();

if ( x == a ) {
cout<<"hey thats it!\n";
}
if ( x > a ) {
}
if ( x < a ) {
cout<< a <<endl;
}
}
cin.get();
}
//end of program```

2. Well, yes. If you don't change the random number seed (using srand), the random numbers won't change.

Specifically, do something like this ONCE at the start of main
srand( time(NULL) );

4. ok it works fine now....

5. another thing you might try, if you're running linux or some other system that implements it is the following:

Code:
```#include <sys/types.h>
#inlcude <sys/stat.h>
#include <fcntl.h>

unsigned int my_rand()
{
unsigned int number;
int fd = open("/dev/random", O_RDONLY);
close(fd);
return number;
}```
this is likely to be a better source of random numbers than rand().

6. Originally Posted by Elkvis
another thing you might try, if you're running linux or some other system that implements it is the following:

Code:
```#include <sys/types.h>
#inlcude <sys/stat.h>
#include <fcntl.h>

unsigned int my_rand()
{
unsigned int number;
int fd = open("/dev/random", O_RDONLY);