Skip to content

Instantly share code, notes, and snippets.

@travisperson
Created October 16, 2012 04:30
Show Gist options
  • Save travisperson/3897243 to your computer and use it in GitHub Desktop.
Save travisperson/3897243 to your computer and use it in GitHub Desktop.
Roll Dice
#include <stdio.h>
#include <stdlib.h>
void roll(int dice[5])
{
int i =0;
for ( i = 0; i < 5; i++ )
{
dice[i] = rand() % 6 + 1;
}
}
int main ()
{
int d[5] = {0};
int i =0;
roll (d);
for ( i = 0; i<5; i++)
{
printf("%d. %d\n", i+1, d[i]);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment