#include<stdio.h>
int sumofDie(int value1, int value2);
int main( void ){
int die1[7];
int die2[7];
int i;
srand(time(NULL));
printf("Rolling die 1 ..........\n");
for( i = 0; i < 6; i++){
int value;
value = 1 + rand() % 6;
die1[i] = value;
}
printf("Rolling die 2......\n");
for ( i = 0; i < 6; i++){
int value;
value = 1 + rand() % 6;
die2[i] = value;
}
for( i = 0; i < 6; i++){
printf("The %d value of the array of the first die is: %d \n", i + 1, die1[i]);
if ( i == 6){
int k;
printf("\n");
for( k = 0; k < 6; k++){
printf("The %d value of the array of the second die is: %d\n", k + 1, die2[k]);
}
}
}
sumofDie(die1,die2);
return 0;
}
int sumofDie( value1, value2){
int sum = 0;
int i;
for( i = 0; i < 6; i++){
sum = value1[i] + value2[i];
if ( i == 6){
return sum;
}
}
}
I've probably done it a very long way, even though there's a simpler way to do it, but come on: I did this program to "capture" the random numbers of two 6-sided data and then add them up. I tried to use a function in the end to practice more what I've been learning so far, but it happens that when I try to compile, an error that I still do not know identifies to appear > expected 'int' but argument is of type 'int *' I searched in some places and saw some people commenting on pointers, I have not yet entered this subject in C and, if that is the case, should I do this program so that I use smokes function to add up the final value?