-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRandomNumbers.c
More file actions
21 lines (17 loc) · 762 Bytes
/
RandomNumbers.c
File metadata and controls
21 lines (17 loc) · 762 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
// Pseudo random numbers = a set of values or elements that are statistically random (Don't use these for any sort of cryptographic security)
srand(time(0)); // "s" for "seed", "rand" for random. And we use current time as the seed
int number1 = (rand() % 6) + 1; // rand() will give you a number between 0 and 32767
// Here we use "%" to indicate the maximum number we would like to generate
// Now it will give us a number between 0+1 and 5+1, that is between 1 and 6
int number2 = (rand() % 6) + 1;
int number3 = (rand() % 6) + 1;
printf("%d\n", number1);
printf("%d\n", number2);
printf("%d\n", number3);
return 0;
}