I need help on getting started with a dice program that will output as many random numbers from 1 to 6 and as many rolls as the user requests, and then how many times each number shows up from the number of rolls (occurrences).. .and the corresponding percent. I'm supposed to use a loop (while, for) and some "do". . . I'm lost. Please help!
So far, this is what I have. . .
[code=c]
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main ()
{
int x;
int Rolls;
int DiceNumber;
int Number;
int FinalRoll;
int D1;
int D2;
int D3;
int D4;
int D5;
int D6;
double Occurances;
double Percent;
//Initialize Random Seed
srand ( time(NULL) );
//Rolling die
Number = rand() %6 + 1;
x = 0
D1 = 0
D2 = 0
D3 = 0
D4 = 0
D5 = 0
D6 = 0
do {
printf("Enter the number of times you want to roll the die:\n");
scanf("%d", &Rolls);
if
while (x < Rolls) {
Percent = Occurances / Rolls
printf("%6c,%3d ,%6c%3d%8c%7.2f \n", DiceNumber, ' ', Occurances, ' ', Percent);
return 0;
}[/code]
So far, this is what I have. . .
[code=c]
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main ()
{
int x;
int Rolls;
int DiceNumber;
int Number;
int FinalRoll;
int D1;
int D2;
int D3;
int D4;
int D5;
int D6;
double Occurances;
double Percent;
//Initialize Random Seed
srand ( time(NULL) );
//Rolling die
Number = rand() %6 + 1;
x = 0
D1 = 0
D2 = 0
D3 = 0
D4 = 0
D5 = 0
D6 = 0
do {
printf("Enter the number of times you want to roll the die:\n");
scanf("%d", &Rolls);
if
while (x < Rolls) {
Percent = Occurances / Rolls
printf("%6c,%3d ,%6c%3d%8c%7.2f \n", DiceNumber, ' ', Occurances, ' ', Percent);
return 0;
}[/code]
Comment