how to make rng in c 2b 2b

Solutions on MaxInterview for how to make rng in c 2b 2b by the best coders in the world

showing results for - "how to make rng in c 2b 2b"
Silvana
12 Aug 2016
1#include <stdio.h>
2#include <stdlib.h>
3#include <ctime>
4
5int main() {
6  srand((unsigned) time(0));
7    printf("Your dice has been rolled! You got: \n ");
8    int result = 1 + (rand() % 6);
9    printf("%d \n", result);
10   switch (result) {
11    case 1:
12        printf("Your prize is our original T-shirt!");
13        break;
14    case 2:
15        printf("Your prize is our original cap!");
16        break;
17    case 3:
18        printf("Your prize is our original necklace!");
19        break;
20    case 4:
21        printf("Your prize is our original keychain!");
22        break;
23    case 5:
24        printf("Your prize is our original cup set!");
25        break;
26    case 6:
27        printf("Your prize is a set of original keychains!");
28        break;
29    default:
30        printf("Error");
31        break;
32    }
33}