Originally posted by namcintosh
by guessing and randomly (sic) copying and pasting snippets of code.
kind regards,
Jos
int result= 1+rand()%500;
int main()
{
unsigned seed;
cout << "Enter a seed value: " ;
cin >> seed;
srand(time(0));
cout << rand()%500 << endl;
cout << rand()%500 << endl;
cout << rand()%500 + rand()%500;
getch();
return 0;
}
int main()
{
unsigned seed;
cout << "Enter a seed value: " ;
cin >> seed;
srand(time(0));
cout << rand()%500 << endl;
cout << rand()%500 << endl;
cout << rand()%500 + rand()%500;
getch();
return 0;
}
int num = rand();
Comment