this exaplanation is based on
youtube channel "coding
experiments".please watch that
video first then read this
document.
first of all like all C programs
we added library [Link]
'stdio.h',stdlib.h' and 'time.h'
for using standard input
output,standard library, and time
header files [Link] this
tutorial we will use pseudo
random number generating
algorithm .to use this algorithm
C provides two strong standard
library functions namely rand()
and srand().both have their own
works in this [Link]()
function is used to generate as
much as random numbers as we
want.a disadvantage of using
rand() without srand() is that it
will always generate same numbers
every time we run the [Link]
is because pseudo algorithm uses
a seed value to generate random
[Link] this case every time
seed value is same which is it's
default value it will generate
same [Link] overcome this
limitation we mannually setupped
seed value for [Link] is
done by function srand().
The parameter passed to it is the
seed value we [Link] our case we
want changing seed values so we
used time().time() function
returns current [Link] time
is continuosly changing so we can
use current time as our seed
[Link]() function needs a
parameter which is the base
address of a varible where we
want to save current [Link]
passed simply NULL to time()
because we do not want to save
time in our code.
At last we simply printed these
numbers in a loop with standard
library function printf().