C++ Tutorial - 7 - Arguments in Functions
Top Comments
All Comments (438)
-
According to the documentation of srand, it takes an unsigned int seed. Which means if you don't enter a number, it defaults to 1 (and srand(1) = 41). If you input a variable seed like time, you get actual pseudo random numbers
-
@mole92db Thanks bro
-
always 41
-
I wish it was 42... so close, yet so far.
-
is an integer a whole number where as double could be any number and if it is can a double be a negative number as well
-
WTF i got 41 as well D:
i got scared for a second, then seen that like 200 other people got 41 too
-
Is there a difference between an argument and a parameter?
-
@CloudDecim There is no point until you are aiming for a bigger project. Else the mind works perfectly, and I rather say it's a better idea to just name your cpp files after what it does.
-
@16yearoldwhiteboy seeding random number generator
-
@mole92db Where did you learn how to do that? What does srand(time(0)) mean?
bullshit i got 41 too. thumbs up if you too got 41
aphillips888 7 months ago 129
To generate the random number put:
srand(time(0));
before:
num1 = rand();
so it looks like this:
double num1;
srand(time(0));
num1 = rand();
cout << "A random number is " << num1 << endl;
mole92db 5 months ago 15