SHARE
TWEET

Fix

a guest Feb 18th, 2020 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. int main() {
  5.    
  6.     srand(0);
  7.     int i = 0, n = 0, count = 0, roll = 0;
  8.     double frequency = 0.0;
  9.     printf("Enter the number of times to roll the dice: ");
  10.     scanf("%d", &n);
  11.     for (i = 0; i < n; i++)
  12.     {
  13.         roll += (rand() % 6) + 1;
  14.         if (roll >= 20)
  15.         {
  16.             count++;
  17.             roll = 0;
  18.         }
  19.     }
  20.     frequency = (((double)count)/ ((double)n) * 100);
  21.     printf("Frequency of the #20 seen: %d", frequency);
  22.    
  23.     return 0;
  24. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top