learn.zybooks.com/zybook/VALENCIACOLLEGECOP2220CReedSpring2023/chapter/2/section/19?content_resource_id=72210404
1 Users
0 Comments
8 Highlights
0 Notes
Tags
Top Highlights
The integers generated by rand() are known as pseudo-random
. For the first call to rand(), no previous random integer exists, so the function uses a built-in integer known as the seed
A programmer can change the seed using the function srand(), as in srand(2) or srand(99
One way to get a different seed for each program run is to use the current time as the seed.
he function time() returns the number of seconds since Jan 1, 1970
#include <time.h>
srand((int)time(0));
The sequence will differ than if srand() was not called (which is the same as srand(1)), but that sequence will be the same for every program run.
Glasp is a social web highlighter that people can highlight and organize quotes and thoughts from the web, and access other like-minded people’s learning.