Have an array -

Code:

int Dice[5] //5 dice in yahtzee?

Use a for loop to fill the array w/ random values

Code:

int i;
srand((unsigned)TIME(NULL));
for(i=0;i<5;i++)
{
//fill w/ random number between 0&5 and add 1 (1-6)
Dice[i] = (rand()%6)+1
}

Have your button send the dice value you want to count to a function

The function should be similar to this

Code:

int Calculate(int value)
{
int n,count;
for(n=0;n<5;n++)
{
if(Dice[n] == value)
{
count++;
}
return count;
}

then use something like

Code:

int ones,twos;
ones = Calculate(1);
twos = Calculate(2);
...

hope this helped