In: Computer Science
C# Yahtzee Program
I am creating a Yahtzee program where you have the option to choose 5 or more dice that will be rolled. I just need help trying to create a random dice roll and seeding it. Could you give me some code examples of getting a dice roll of a six sided die that won't display similar results.
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
int main()
{ int dice[100],n,i;
while(1){
printf("Enter no of dice(>=5):");
scanf("%d",&n);
if(n>=5)
break;
else
printf("please enter correct no of dice\n");
}
printf("rolling the %d dice resulted:\n",n);
srand(time(0));
for (i = 0; i < n; i++) {
int num = (rand() % 6) +1;
printf("%d ", num);
}
return 0;
}