2 Answers

New Answer#include <stdio.h> #include <stdlib.h> #include <time.h> int main() { srand(time(NULL)); int num=0; printf("How many times you want to roll dice: "); scanf("%d",&num); printf("\nYou entered: %d\n\n",num); int ones = 0, twos = 0, threes = 0, fours = 0, fives = 0, sixes = 0; for(int i = 0; i < num; i++) { int dice=1+rand()%6; if(dice==1) ones++; else if(dice==2) twos++; else if(dice==3) threes++; else if(dice==4) fours++; else if(dice==5) fives++; else if(dice==6) sixes++; } printf("Number One on dice came %d times\n",ones); printf("Number Two on dice came %d times\n",twos); printf("Number Three on dice came %d times\n",threes); printf("Number Four on dice came %d times\n",fours); printf("Number Five on dice came %d times\n",fives); printf("Number Six on dice came %d times\n",sixes); return 0; }