-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrand0driver.c
More file actions
41 lines (32 loc) · 905 Bytes
/
rand0driver.c
File metadata and controls
41 lines (32 loc) · 905 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/* Random number generator
rand0driver.c -- driver program for rand0.c
run with rand0.c
*/
#include<stdio.h>
#include<string.h>
extern unsigned int rand0();
extern void srand0(unsigned int);
extern unsigned long int seed;
int main(void)
{
// Stores the number of random numbers generated every call
int count = 0;
// Stores the random number to be printed
unsigned int num = 0;
printf("Welcome to Random Number Generator!\n");
printf("How many random number would you like? \n");
scanf("%d", &count);
// User initializing the seed value
printf("Kindly choose a seed value:\n");
while(scanf("%ld", &seed) == 1)
{
for(int i = 1; i <= count; i++)
{
num = rand0();
printf("\n%d: %d", i, num);
srand0(seed);
}
printf("\nPlease enter the next seed or 'q' to quit\n");
}
return 0;
}