Question

Find "your number": take your account (ex 750 for s750 ), compute MOD 4, add 1....

Find "your number": take your account (ex 750 for s750 ), compute MOD 4, add 1. So for 750, that result is 3

Using a seed value of 11, and 10 rolls of a 4-sided dice, how many times did your number ( ex. 3 ) appear

Program description:

Code in C

Roll a 4 sided dice, 10 times

Count how many of each 1,2,3,4 were observed

0 0
Add a comment Improve this question Transcribed image text
Answer #1

C Code:

#include <stdio.h>

#include <stdlib.h>

#include<time.h>

// Driver program

int main(void)

{

int l=1,u=4,i1=0,i2=0,i3=0,i4=0;

  srand(time(0));

  for(int i = 0; i<10; i++){

    int num = (rand() %(u - l + 1)) + l;

if(num==1)

i1++;

else if(num==2)

i2++;

else if(num==3)

i3++;

else

i4++;

}

printf("The 4 sided dice when rolled 10 times has\n1 - %d times\n2 - %d times\n3 - %d times\n4 - %d times\n",i1,i2,i3,i4);

  return 0;

}

output-

if you like the answer please provide a thumbs up.

Add a comment
Know the answer?
Add Answer to:
Find "your number": take your account (ex 750 for s750 ), compute MOD 4, add 1....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • (1 point) Using an if Statement In a Loop A common thing to do is to...

    (1 point) Using an if Statement In a Loop A common thing to do is to use variables to keep track of some sort of count. When used in a loop we count things very quickly. Scenario: If you roll a pair of dice, rolling a 12 (two sixes) is rare. How rare? If you were to roll a pair of dice 1,000 times, on average, how many times would it come up as 12? To figure this out, we...

  • The Dice game of "Pig" can be played with the following rules. 1. Roll two six-sided dice. Add the face values...

    The Dice game of "Pig" can be played with the following rules. 1. Roll two six-sided dice. Add the face values together. 2. Choose whether to roll the dice again or pass the dice to your opponent. 3. If you pass, then you get to bank any points earned on your turn. Those points become permanent. If you roll again, then add your result to your previous score, but you run the risk of losing all points earned since your...

  • need help with dice excercise For example, if we were writing a calendar program of some...

    need help with dice excercise For example, if we were writing a calendar program of some sort, we might very well use an array with 366 spots to hold the days, not worrying about adding more days to the year. Exercise 23 (C level] For another example, suppose we want to simulate rolling two six-sided dice repeatedly, tallying how many times each total is rolled. We need a memory cell to count the number of times each of the possible...

  • Problem 9 A single game of craps (a dice game) consists of at most two rolls...

    Problem 9 A single game of craps (a dice game) consists of at most two rolls of a pair of six sided dice. The ways to win are as follows: Win-the first roll of the pair of dice sums to either 7 or 1 (you win, game over, no second roll Win the first roll of the pair of dice does NOT sum to either 7 or 1 but the sum of the second roll is equal to the sum...

  • Can anyone help me with this java program? We are still very early with lessons so...

    Can anyone help me with this java program? We are still very early with lessons so no advanced code please. And if you comment throughout the code that would be incredibly helpful. Thank you Create 2 Java files for this assignment: Die.java and TestDie.java Part 1 - The Die Class             The program Design a Die class that contains the following attributes: sides: represents how many sides a dice has. A dice usually has 6 sides but sometimes could have...

  • Exercise I: More dice rolls You repeatedly throw a dice. 1. Compute the probability of the...

    Exercise I: More dice rolls You repeatedly throw a dice. 1. Compute the probability of the following events. Write these events precisely using other events, and say where you use assumptions such as independence or disjoint- ness. Give your results as a single simplified fraction. (a) The first roll is even and the second one is odd. (b) The first five rolls are even. (c) The first roll is even and the second one is odd, or the first roll...

  • . 9. 10. 1. 11. 12. 13. 1. 14. 15. 16 2.1.3.4.1.5. 16. 17:18 Write a...

    . 9. 10. 1. 11. 12. 13. 1. 14. 15. 16 2.1.3.4.1.5. 16. 17:18 Write a int method rolID20(int int m, Randomr) that returns how many times It takes to roll two numbers with a single 20 sided dice. The parameters to the method are as follows: into The first number you are trying to roll int m The second number you are trying to roll Randomr A Random object to simulate the dice rolls. Please see the documentation for...

  • 2. (25 points) Sekora International Casino (SIC) is launching a new game making use of fair 6-sided dice . In phase 1, roll two 6-sided dice and compute the difference between the rolls. Call thi...

    2. (25 points) Sekora International Casino (SIC) is launching a new game making use of fair 6-sided dice . In phase 1, roll two 6-sided dice and compute the difference between the rolls. Call this difference . In phase 2, roll r dice, and add up the total of the rolls. This is the payout in dollars of the game. (with the numbers 1-6 on the sides). The game proceeds in two phases as follows: (a) (5 points) In the...

  • Random Number Generation and Static Methods Write a program that simulates the flipping of a coin...

    Random Number Generation and Static Methods Write a program that simulates the flipping of a coin n-times to see how often it comes up heads or tails. Ask the user to type in the number of flips (n) and print out the number of times the coin lands on head and tail. Use the method ‘random()’ from the Math class to generate the random numbers, and assume that a number less than 0.5 represents a tail, and a number bigger...

  • Instructions sevens.py 1 # Put your code here In the game of Lucky Sevens, the player...

    Instructions sevens.py 1 # Put your code here In the game of Lucky Sevens, the player rolls a pair of dice. If the dots add up to 7, the player wins $4; otherwise, the player loses $1. Suppose that, to entice the gullible, a casino tells players that there are lots of ways to win: (1,6), (2,5), and so on. A little mathematical analysis reveals that there are not enough ways to win to make the game worthwhile; however, because...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT