so i was given the assignment where i am suppose to use the random number generator to simulate dice throws and also calculate the probability of the dice landing on a specific facevalue.
Here is my program....
/* put this in a program */
Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define MAX 6 /* symbolic constant */
int main()
{
int faceValue = 0 ;
float probability[MAX] = {0} ;
int run = 0 ;
int counter = 0 ;
srand(time(0));/*random number generator*/
printf("How many times do you want to throw the die? \n");
scanf("%d",&run);
faceValue = rand() % 6 + 1;
switch(faceValue){
case 1:
faceValue == 1;
break;
case 2:
faceValue == 2;
break;
case 3:
faceValue == 3;
break;
case 4:
faceValue == 4;
break;
case 5:
faceValue == 5;
break;
case 6:
faceValue == 6;
break;
}
for (counter =1; counter <= MAX; counter++)
{
printf(" The probability for number %d is %0.2f %\n", counter, (probability[counter]/12)* 100);
}
return 0;
}
the problem is when i compile i don't get the calculations correct for the probability....could someone please point me to the write direction cause i do not no where to go from here