Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include <stdio.h>
- #include <stdlib.h>
- int main() {
- srand(0);
- int i = 0, n = 0, count = 0, roll = 0;
- double frequency = 0.0;
- printf("Enter the number of times to roll the dice: ");
- scanf("%d", &n);
- for (i = 0; i < n; i++)
- {
- roll += (rand() % 6) + 1;
- if (roll >= 20)
- {
- count++;
- roll = 0;
- }
- }
- frequency = (((double)count)/ ((double)n) * 100);
- printf("Frequency of the #20 seen: %d", frequency);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement