Question

write a function simulate the rolling of a roulette wheel (38 possible outcomes numbered 0-37)print the...

write a function simulate the rolling of a roulette wheel (38 possible outcomes numbered 0-37)print the result of the roll (0-37).
update the number of times the result is equal to 17.
update the number of times the wheel has been rolled.
struct prob17{   
int times17;
int rolls;
};
void rollWheel(struct prob 17 * wheel)
0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include<stdio.h>
#include<stdlib.h>

struct prob17{
   int times17;
   int rolls;
};
void rollWheel(struct prob17 * wheel);

int main(){
   struct prob17* wheel;
   while(1){
       printf("Enter \n1 to roll\n2 to stop:\n");
       int choice;
       scanf("%d",&choice);
       if(choice==1){
           rollWheel(wheel);
       }else if(choice==2){
           break;
       }else{
           printf("Invalid choice\n");
       }
   }
   printf("Number of times result is equal to 17: %d\n",wheel->times17);
   printf("Number of times wheel has been rolled: %d\n",wheel->rolls);
}

void rollWheel(struct prob17 * wheel){
   wheel->rolls++;
   int outcome=rand()%37;
   printf("\n\nResult of roll is : %d\n\n",outcome);
   if(outcome==17){
       wheel->times17++;
   }
}

Output::

Enter
1 to roll
2 to stop:
1


Result of roll is : 34

Enter
1 to roll
2 to stop:
1


Result of roll is : 35

Enter
1 to roll
2 to stop:
1


Result of roll is : 5

Enter
1 to roll
2 to stop:
1


Result of roll is : 9

Enter
1 to roll
2 to stop:
1


Result of roll is : 19

Enter
1 to roll
2 to stop:
1


Result of roll is : 35

Enter
1 to roll
2 to stop:
1


Result of roll is : 29

Enter
1 to roll
2 to stop:
1


Result of roll is : 15

Enter
1 to roll
2 to stop:
1


Result of roll is : 22

Enter
1 to roll
2 to stop:
1


Result of roll is : 31

Enter
1 to roll
2 to stop:
1


Result of roll is : 35

Enter
1 to roll
2 to stop:
1


Result of roll is : 17

Enter
1 to roll
2 to stop:
1


Result of roll is : 28

Enter
1 to roll
2 to stop:
1


Result of roll is : 16

Enter
1 to roll
2 to stop:
1


Result of roll is : 4

Enter
1 to roll
2 to stop:
1


Result of roll is : 2

Enter
1 to roll
2 to stop:
1


Result of roll is : 13

Enter
1 to roll
2 to stop:
1


Result of roll is : 18

Enter
1 to roll
2 to stop:
1


Result of roll is : 10

Enter
1 to roll
2 to stop:
1


Result of roll is : 15

Enter
1 to roll
2 to stop:
1


Result of roll is : 29

Enter
1 to roll
2 to stop:
1


Result of roll is : 4

Enter
1 to roll
2 to stop:
1


Result of roll is : 9

Enter
1 to roll
2 to stop:
1


Result of roll is : 3

Enter
1 to roll
2 to stop:
1


Result of roll is : 29

Enter
1 to roll
2 to stop:
1


Result of roll is : 6

Enter
1 to roll
2 to stop:
1


Result of roll is : 12

Enter
1 to roll
2 to stop:
1


Result of roll is : 22

Enter
1 to roll
2 to stop:
1


Result of roll is : 18

Enter
1 to roll
2 to stop:
1


Result of roll is : 11

Enter
1 to roll
2 to stop:
1


Result of roll is : 27

Enter
1 to roll
2 to stop:
1


Result of roll is : 30

Enter
1 to roll
2 to stop:
1


Result of roll is : 10

Enter
1 to roll
2 to stop:
1


Result of roll is : 10

Enter
1 to roll
2 to stop:
1


Result of roll is : 17

Enter
1 to roll
2 to stop:
1


Result of roll is : 7

Enter
1 to roll
2 to stop:
1


Result of roll is : 8

Enter
1 to roll
2 to stop:
1


Result of roll is : 10

Enter
1 to roll
2 to stop:
1


Result of roll is : 0

Enter
1 to roll
2 to stop:
1


Result of roll is : 30

Enter
1 to roll
2 to stop:
1


Result of roll is : 19

Enter
1 to roll
2 to stop:
1


Result of roll is : 35

Enter
1 to roll
2 to stop:
1


Result of roll is : 25

Enter
1 to roll
2 to stop:
1


Result of roll is : 10

Enter
1 to roll
2 to stop:
1


Result of roll is : 29

Enter
1 to roll
2 to stop:
1


Result of roll is : 8

Enter
1 to roll
2 to stop:
1


Result of roll is : 28

Enter
1 to roll
2 to stop:
1


Result of roll is : 5

Enter
1 to roll
2 to stop:
1


Result of roll is : 4

Enter
1 to roll
2 to stop:
1


Result of roll is : 1

Enter
1 to roll
2 to stop:
1


Result of roll is : 36

Enter
1 to roll
2 to stop:
1


Result of roll is : 33

Enter
1 to roll
2 to stop:
1


Result of roll is : 21

Enter
1 to roll
2 to stop:
1


Result of roll is : 8

Enter
1 to roll
2 to stop:
1


Result of roll is : 0

Enter
1 to roll
2 to stop:
1


Result of roll is : 13

Enter
1 to roll
2 to stop:
1


Result of roll is : 29

Enter
1 to roll
2 to stop:
1


Result of roll is : 27

Enter
1 to roll
2 to stop:
1


Result of roll is : 35

Enter
1 to roll
2 to stop:
1


Result of roll is : 25

Enter
1 to roll
2 to stop:
1


Result of roll is : 1

Enter
1 to roll
2 to stop:
1


Result of roll is : 25

Enter
1 to roll
2 to stop:
1


Result of roll is : 19

Enter
1 to roll
2 to stop:
2
Number of times result is equal to 17: 3
Number of times wheel has been rolled: 63

Add a comment
Know the answer?
Add Answer to:
write a function simulate the rolling of a roulette wheel (38 possible outcomes numbered 0-37)print the...
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
  • Simulate the flipping of a coin Print the result of the coin flip : use off...

    Simulate the flipping of a coin Print the result of the coin flip : use off numbers for Heads . and even numbers for Tails Update the number of times the result is Heads Update the number of times the coin has been flipped struct coin_prob{ int heads; int flips; }; void coin_flip(struct coin_prob * coin); You may use a rand functioon (assume its already been seeded), but no other pre-defined function

  • Problem 3 (Quiz). Recall that an American Roulette wheel has 38 possible outcomes, 18 black, 18...

    Problem 3 (Quiz). Recall that an American Roulette wheel has 38 possible outcomes, 18 black, 18 red and 2 green. The numbers go from 1 to 36, and the green outcomes are numbered 0 and 00. Someone places İO bets on "1st 12", that is, that person wins if the outcome is any number between 1 and 12, included. 1. What is the probability of losing 8 out of the 10 total bets?

  • A roulette wheel has 38 numbered slots (1 through 36, 0, and 00). Of the 38...

    A roulette wheel has 38 numbered slots (1 through 36, 0, and 00). Of the 38 compartments, 18 are black, 18 are red and 2 are green. A play has the dealer (called the “croupier”) spin the wheel and a small ball in opposite directions. As the ball comes to a stop, it can land with equal probability on any of the 38 numbered slots. Find the probability of green occurring on two consecutive plays?

  • A roulette wheel has 38 slots, numbered 0 , 00 , and 1 to 36 ....

    A roulette wheel has 38 slots, numbered 0 , 00 , and 1 to 36 . The slots 0 and 00 are colored green, 18 of the others are red, and 18 are black. The dealer spins the wheel and, at the same time, rolls a small ball along the wheel in the opposite direction. The wheel is carefully balanced so that the ball is equally likely to land in any slot when the wheel slows. Gamblers can bet on...

  • 2. (From the Fall 2017 takehome.) In American roulette, a roulette wheel with 38 possible outcomeste...

    2. (From the Fall 2017 takehome.) In American roulette, a roulette wheel with 38 possible outcomeste numbers 1 to 36, "0", and "00" is spun. As the wheel spins, players makes bets on which number the ball w land on. Eventually the wheel stops, and a ball lands randomly on one of the 38 numbers, with an equal probability for each one. A statistics professor's father bets that the wheel wil land on one of the numbers from 1 to...

  • In the game of​ roulette, a wheel consists of 38 slots numbered​ 0, 00,​ 1, 2,...,...

    In the game of​ roulette, a wheel consists of 38 slots numbered​ 0, 00,​ 1, 2,..., 36. To play the​ game, a metal ball is spun around the wheel and is allowed to fall into one of the numbered slots. If the number of the slot the ball falls into matches the number you​ selected, you win​ $35; otherwise you lose​ $1. Complete parts ​(a) through ​(g) below. Construct a probability distribution for the random variable​ X, the winnings of...

  • In the game of roulette, a wheel consists of 38 slots numbered 0.00, 1.2.36. To play...

    In the game of roulette, a wheel consists of 38 slots numbered 0.00, 1.2.36. To play the game, a metal ball is spun around the wheel and is allowed to fall into one of the numbered slots in the number of the let the ball fall into matches the number you selected, you win $35; otherwise you lose $1. Complete parts (a) through (a) below. ber t he standard nommal darbuon page 1. Sick here the standard nomadsbution table (page...

  • A Roulette wheel has 38 slots numbered 0 to 36 and 00. The wheel is spun and a ba...continues

    A Roulette wheel has 38 slots numbered 0 to 36 and 00. The wheel is spun and a ball is thrown into the wheel and comes to rest in one of the slots. There are numerousof ways to bet, individual numbers, groups of numbers (1-12, 13-24, etc), by color (half of the numbers are black and the half are red), and in various othercombinations. This problem is going to focus on betting $1.00 on the number group 1-12. If the...

  • A roulette wheel has 38 slots, numbered 0, 00, and 1 to 36. The slots 0...

    A roulette wheel has 38 slots, numbered 0, 00, and 1 to 36. The slots 0 and 00 are colored green, 18 of the others are red, and 18 are black. The dealer spins the wheel and at the same time rolls a small ball along the wheel in the opposite direction. The wheel is carefully balanced so that the ball is equally likely to land in any slot when the wheel slows. Gamblers can bet on various combinations of...

  • Write a C PROGRAM that will simulate rolling a die. When rolling a die, one will...

    Write a C PROGRAM that will simulate rolling a die. When rolling a die, one will get a die face value of 1-6. We can use rand function and math ceiling function to get a random number of 1-6 generated. The program will simulating rolling 5 dice simultaneously and store their face values into an array of size 5. The program will keep rolling the dice and print the following: 1. All face values in one line 2. If any...

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