Write your function so that it returns an array of dice

Assignment Help Basic Computer Science
Reference no: EM13774616

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) { 

Reference no: EM13774616

Questions Cloud

Content analysis and statistical analysis : Describe your plans for analyzing your data (e.g., content analysis, statistical analysis, etc.) and your plans for how you will present your results.
Question regarding the merchandise inventory items : A company just starting in business purchased three merchandise inventory items at the following prices. First purchase $80; Second purchase $95; Third purchase $85. If the company sold two units for a total of $240 and used FIFO costing, the gros..
What is meant by the term due process of the law : What is meant by the term due process of the law? What does the term multiculturalism and how does it affect criminal justice
Converting from an erd to a table design : Converting from an ERD to a table design. Computer-aided software engineering applications that help improve the productivity of information systems professional working on large projects.
Write your function so that it returns an array of dice : 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..
Describe the interrelatedness of criminal justice system : Describe the interrelatedness of the 3 components of the criminal justice system
Project management process groups : Explain how the project management process groups are similar to, yet different from, the project life cycle structure.
Major steps of the process maria will have to oversee : Which documents should Maria read before her class? Based on what you know about ISO 27000 program certification, what are the major steps of the process Maria will have to oversee?
Composition of earth atmosphere : Summarize the scienti?c data that indicate global warming is occurring as a result of human activity. What is the composition of Earth's atmosphere, and how has life a?ected the atmosphere during the past several billion years?

Reviews

Write a Review

 

Basic Computer Science Questions & Answers

  Gradesaverage, which prompts user

Write a program called GradesAverage, which prompts user for the number of students, reads it from the keyboard, and saves it in an int variable called numStudents. It then prompts user for the grades of each of the students and saves them in an i..

  Sketch a normal.probability plot to check the normality

If it is a t test, sketch a normal.probability plot to check the normality of the population.6. State the null and alternative hypothesis.7. Decide on the significance level, alpha.

  What will be its approximate speed in rpm

An AC inductor motor is rated at 1750 rpm with a line frequency of 60hz. If the motor is operated on a 50 hz line, what will be its approximate speed in rpm.

  Write a program that translates a number

Write a program (called Grades) that translates a number between 0 and 4 into the closest letter grade. For example, the number 2.8 (which might have been the average of several grades) would be converted to B-. Break ties in favor of the better g..

  Determine the depth from the ground surface

One of which is to measure groundwater table or in other words they are used to determine the depth from the ground surface to groundwater surface.

  Explaining vulnerability in novice programmer-s code

You have found vulnerability in novice programmer's code and have recommended sweeping changes in your organization to address issues.

  What is ldap and what are its security vulnerabilities

Why do you think an organization would continue to use directory services that have known security flaws?

  List a list of items for sale of a particular customer

Enter a bid for an item and the bids are stored in an STL priority_queue object. This allows the highest bid to be at front of the queue.

  M uses the average and maximum error of the two values. c.

A Atmega128 is being used to monitor humidity inside test chamber 03. The device uses two sensors to have some fault tolerance.

  The database specification

The database specification

  What is the global cpi for each implementation?

Given a program with a dynamic instruction count of 1.0E6 instructions divided into classes as follows: 10% class A, 20% class B, 50% class C, and 20% class D, which implementation is faster?"

  Design a file system checker for our file system

Design a file system checker for our file system. You should call it csefsck. It will have to do the following: The DeviceID is correct All times are in the past, nothing in the future Validate that the free block list is accurate this includ..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd