(C code) Each die has its own function, and I want a function that will sum the outcome of each die. But how do I retrieve the values from the first and second functions and put them into the third to sum them? See below
int roll_die1(void)
{
int random_int;
srand((unsigned int)time(NULL));
random_int = rand() % (6) + 1;
printf("The outcome of your first Roll is: %d.\n", random_int);
return random_int;
}
int roll_die2(void)
{
int random_int2;
srand((unsigned int)time(NULL));
random_int2 = rand() % (6) + 1;
printf("The outcome of your second Roll is: %d.\n", random_int2);
return random_int2;
}
int calculate_sum_dice(int die1_value, int die2_value)
{
int sum = die1_value + die2_value;
return sum;
}
Now I can't just call the first two functions into the 3rd function, because it would repeat all the steps in those functions, so how do I do it?
Edit: In my main.c, to get the sum I did
roll1 = roll_die1();
roll2 = roll_die2();
sum = calculate_sum_dice(roll1, roll2);