rand() only returns 41
I'm trying to use the rand function but for some reason it always returns 41. Any thoughts?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
#include <iostream>
using namespace std;
int main()
{
int randNumber = rand();
cout << randNumber;
char wait;
cin >> wait;
return 0;
}
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
int main()
{
srand(time(NULL));
int randNumber = rand();
cout << randNumber;
char wait;
cin >> wait;
return 0;
}
|
Topic archived. No new replies allowed.