For our homework, we have to write a program that simulates a lottery, randomly drawing 3 balls numbered 1 through 10. The user inputs the # of drawings. What I don't get is how to show the percentage of times the number(s)drawn are 7, 1 2 & 3, or even numbers. Can anyone give me any suggestions on how to do counters to show these percentages. This code works except for doing the percentages.
Code:#include <stdio.h> #include <stdlib.h> main() { unsigned int seed; int a=1, b=10, k; int rand_int(int a, int b); int numDraw; printf("Enter number of Lottery Drawings to simulate: "); scanf("%i", &numDraw); printf("\nEnter a positive integer seed value: "); scanf("%u",&seed); srand(seed); while (numDraw > 0) { for (k=1; k<=3; k++) { printf("%i ",rand_int(a,b)); } printf("\n"); numDraw--; } return 0; } int rand_int (int a, int b) { return rand()%(b-a+1) + a; }



LinkBack URL
About LinkBacks


