Expand|Select|Wrap|Line Numbers
- //This Program Creates the Sum of a Number of Dice Rolls of the Same Size
- #include <stdio.h>
- #include <math.h>
- #include <time.h>
- int rolldie();
- int main(){
- int x, n, a; //'x' n=number of rolls, a=number sided dice
- printf ("Please Enter the Number Sided Dice Followed by the number of Rolls... %d");
- scanf ("%d%d", &a, &n);
- srand(time(0));
- for(x=0;x<n;x++)
- printf("%d ",rolldie(a,n));
- return 0;
- }
- int rolldie(int c)
- {
- return 1 + rand() %c;
- }
Please Enter the Number Sided Dice Followed by the number of Rolls... 12 10
4 12 2 10 12 5 5 12 12 5 >Exit code: 0