Question

in C++ i need a random number generator, numbers 1-6, so a dice roll program.   

in C++
i need a random number generator, numbers 1-6, so a dice roll program.   

Homework Answers

Answer #1

Solution

Code

#include <iostream>
#include<ctime>
using namespace std;

int main()
{
srand((unsigned) time(0));
cout<<"After rolling dice : ";
int dice = 1 + (rand() % 6);
cout<<dice;
}

Screenshot

Output

Know the answer?
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
Similar Questions
Design an application that uses the C# random generator to randomly roll a six face dice...
Design an application that uses the C# random generator to randomly roll a six face dice ( no 1 - no 6) . If the user rolled a 3, the user gets to roll the six face die again. You must use a switch statement to write the result /s of the random dice roll/s to the screen. Hint: You should have nested switches in your program
I need this coded in R: I have a program that simulates a fair dice. The...
I need this coded in R: I have a program that simulates a fair dice. The program rolls a fair coin 100 times and counts the number of 1's. The simulation is repeated 10^5 times and stored the outcomes in x and a histogram is plotted. I need to now draw a bell curve showing normal/gaussian distribution over the histogram. Code I have: dice <- function(n) { sample(c(1:6),n,replace = TRUE) } x<-dice(100) x<-numeric(10^5) for(n in 1:10^5){ x[n]<-sum(dice(100)==1) } hist(x, main="100...
If you roll a die, you get one of the following numbers: 1, 2, 3, 4,...
If you roll a die, you get one of the following numbers: 1, 2, 3, 4, 5, 6. Each possibility occurs with equal probability of 1/6. The expected value of a dice roll is E(D)= 3.5 and the variance of a dice roll is Var(X) = 2.917. a) Suppose you roll a die and then add 1 to the roll to get a new random variable taking one of the following numbers: 2,3,4,5,6,7. What is the variance of this new...
Suppose we roll a pair of fair dice, let A=the numbers I rolled add up to...
Suppose we roll a pair of fair dice, let A=the numbers I rolled add up to exactly 8, and let B=the numbers I rolled multiply to an even number. Find P(Bc|Ac)
Simulate 1000 rolls of a pair of dice. (Hint: Sounds like a For Loop to me!)...
Simulate 1000 rolls of a pair of dice. (Hint: Sounds like a For Loop to me!) Write a program that simulates a dice roll by picking a random number from 1-6 and then picking a second random number from 1-6.    How many times do you get two 1’s. What many times do you get two 1’s if you simulate 10,000 rolls of a pair of dice? Upload your program and type the answer to the two questions. (remember, these...
Roll two dice and multiply the numbers. What is the probability that the product is a...
Roll two dice and multiply the numbers. What is the probability that the product is a multiple of 6? Group of answer choices A.5/12 B.3/4 C.7/12 D.2/9
I need a program written in C, not C+ or C++. I have no idea how...
I need a program written in C, not C+ or C++. I have no idea how to go about doing it. Basically, I need it to take in the following information and spit out the following for a number table. The operation should be able to take plus, minus, division or multiplication and the low/high row/column numbers should be able to go up to where ever. But I'm sure the following example is fine. Enter low row number: 1 Enter...
A pseudo-random number generator is a mathematical function that produces a sequence of numbers that is...
A pseudo-random number generator is a mathematical function that produces a sequence of numbers that is supposed to appear to be random (which implies uniformly distributed) and is used in simulation. If the generator produces real numbers over the interval from 0.5 to 5.0, what is the probability that a value is between 2.6 and 2.9?
Two people play a game. Person 1 has a 6 sided dice and must roll 5,...
Two people play a game. Person 1 has a 6 sided dice and must roll 5, then 6, successively. Person 2 also has a 6 sided dice and must roll a 6, then a 6, consecutively. i) An observer says that person 1 and 2 have the same probability of obtaining their respective sequence (1/6*1/6=1/36). The observer also says that on average, they both need to throw the same amount of times in order to get the desired outcome. The...
1) Consider a linear congruential random number generator with parameters a = 35, c = 20...
1) Consider a linear congruential random number generator with parameters a = 35, c = 20 and m = 100. a- Generate 5 random numbers by using this method. Use 84. b- By using inverse transform method, generate 2 random variate for an exponential distribution with parameter λ = 0.5. Use the first two random numbers you generated in part a.
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT