SHARE
TWEET

New fix

a guest Feb 18th, 2020 73 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 = 1 + (rand() % 19);
  14.         if (roll == 20)
  15.         {
  16.             count++;
  17.         }
  18.     }
  19.     frequency = (((double)count)/ ((double)n) * 100);
  20.     printf("Frequency of the #20 seen: %d", frequency);
  21.    
  22.     return 0;
  23. }
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