Code:
/*Dice Program*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
int seed, tosses, die_1, die_2, eight=0,x,sum;
double percent
/*seed value*/
printf("Enter a positive seed value: \n");
scanf("%i",seed);
printf("Enter the number of times you want to roll the dice: \n");
scanf("%i",tosses);
/*Equations for the 2 dice*/
srand(seed);
for (x=1; x<=tosses;x++)
{
die_1=rand()%6+1;
die_2=rand()%6+1;
printf("%5i %5i\n", die_1, die_2);
sum=die_1+die_2;
if (sum==8
eight++);
}
printf("The number of eights you rolled is: 5i \n",eights);
percent=((float)eights/tosses*100);
printf("The percent of eights you rolled is 5.2f \n",percent);
/*exit*/
}
Code:
ERRORS
In function `main':
14: error: syntax error before "printf"
28: error: syntax error before "eight"
30: error: `eights' undeclared (first use in this function)
30: error: (Each undeclared identifier is reported only once
30: error: for each function it appears in.)
31: error: `percent' undeclared (first use in this function)