Write your function so that it returns an array of dice


Write a function with one input parameter sum such that the function determines all the possible ways of rolling two dice where the spots shown on the dice add to the sum. Assume that the dice are six-sided. Each side has between 1 and 6 spots. For example, if sum is the value 4, then there are three ways of rolling the dice to get a sum of 4, {1, 3}, {2, 2} and {3, 1}. Write your function so that it returns an array of Dice structs. Each element in the array should be set to indicate one of the possible ways of rolling the sum. The last element in the array should be the special "sentinel" value where both die1 and die2 are zero. So, if the function is called with 4 as the input argument, then the function will return an array with four elements (three actual rolls plus the sentinel roll). Part of this question is declaring a correct return type for your function and correctly creating the array that you return.

struct Dice {
int die1; // spots on first die
int die2; // spots on second die
};

/* declare the correct return type for your function */

diceRolls(int sum) { 

Request for Solution File

Ask an Expert for Answer!!
Basic Computer Science: Write your function so that it returns an array of dice
Reference No:- TGS01044678

Expected delivery within 24 Hours