Question

Can someone let me know what to do for this? In C Programming.

HERE ARE INSTRUCTIONS:

Write function sum Category to do the following a. Return type int b. Parameter list i. int array dice ii. int value category

0 0
Add a comment Improve this question Transcribed image text
Answer #1

The required function is given below:

int sumCategory(int dice[], int category)
{
//variable declration and initialization
int sum = 0;
int die;
  
//calculate the array size
int size = sizeof(dice) / sizeof(dice[0]);
for(int i=0; i<size; i++)
{
die = dice[i];
if(die == category)
sum = sum + dice[i];
}
  
//return statement
return sum;
}

The screenshot of the above source code is given below:

Add a comment
Know the answer?
Add Answer to:
Can someone let me know what to do for this? In C Programming. HERE ARE INSTRUCTIONS:...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Can someone let me know what to do for this? In C Programming. HERE ARE INSTRUCTIONS:...

    Can someone let me know what to do for this? In C Programming. HERE ARE INSTRUCTIONS: it is for a yahtzee game program. Write function sumChance to do the following a. Return type int b. Parameter list array of dice c. Declare int variable sum d. Declare int variable die e. Loop through the dice array adding the value of each die to the variable sum f. Return variable sum Write function checkLgStraight to do the following a. Return type...

  • Can someone let me know what to do for this? In C Programming. HERE ARE INSTRUCTIONS:...

    Can someone let me know what to do for this? In C Programming. HERE ARE INSTRUCTIONS: This is my code for that specific section: void displayScoreCard(int scoreCard[CATEGORIES][COLS]) { printf("\n\n\t\tYAHTZEE SCORECARD\n"); displayUpperSection(scoreCard); displayLowerSection(scoreCard); printf("\t\t+-------------+-------------+\n\n"); printf("+-----------------|-----------|\n"); printf("+ TOTAL (Upper) | %d |\n", ZERO); printf("+-----------------|-----------|\n"); printf("+ GRAND TOTAL | %d |\n", ZERO); printf("+-----------------|-----------|\n\n\n"); } Update function displayScoreCard to do the following a. Declare local variable total set equal to the result from function call sumUpper and checkBonus b. Declare local variable grandTotal set...

  • Can someone let me know what to do for this? In C Programming. HERE ARE INSTRUCTIONS:...

    Can someone let me know what to do for this? In C Programming. HERE ARE INSTRUCTIONS: Here is my code I have that needs to be edited with instructions. : void displayUpperSection(int scoreCard[CATEGORIES][COLS]){ printf("+-----------------|-----------|\n"); printf("+ UPPER SECTION | SCORE |\n"); printf("+-----------------|-----------|\n"); printf("+ ONEs | %d |\n", scoreCard[one][COL]); printf("+-----------------|-----------|\n"); printf("+ TWOS | %d |\n", scoreCard[two][COL]); printf("+-----------------|-----------|\n"); printf("+ THREES | %d |\n", scoreCard[three][COL]); printf("+-----------------|-----------|\n"); printf("+ FOURS | %d |\n", scoreCard[four][COL]); printf("+-----------------|-----------|\n"); printf("+ FIVES | %d |\n", scoreCard[five][COL]); printf("+-----------------|-----------|\n"); printf("+ SIXES | %d...

  • I need help with these Java programming assignements. public class Die { //here you declare your...

    I need help with these Java programming assignements. public class Die { //here you declare your attributes private int faceValue; //operations //constructor - public Die() { //body of constructor faceValue=(int)(Math.random()*6)+1;//instead of 1, use random approach to generate it } //roll operation public void roll() { faceValue=(int)(Math.random()*6)+1; }    //add a getter method public int getFaceValue() { return faceValue; }    //add a setter method public void setFaceValue(int value) { faceValue=value; } //add a toString() method public String toString() { String...

  • java programming!!! Write the code fragment that will do the following: • Ask the user how...

    java programming!!! Write the code fragment that will do the following: • Ask the user how many numbers they want to enter • Declare and instantiate an array of doubles with as many elements as the number entered by the user • Write one 'for' loop to fill the array with data from the user • Write a second 'for' loop to calculate the sum of all of the numbers in the array • Print the calculated sum Note: Write...

  • Can someone finish this class for me? There are comment instructions with what to do in...

    Can someone finish this class for me? There are comment instructions with what to do in the methods already. public class ArrayDemo   {                               public void demonstrateTask1(){                                System.out.println("Demonstrate   Task   1");                                                               int[]   numbers =   null;   //   note   that   numbers   references   nothing   (null)   initially                           ...

  • Can someone please help me with this code? I'm writing in C++. Thank you in advance....

    Can someone please help me with this code? I'm writing in C++. Thank you in advance. Complete a program that represents a Magic Eight Ball (a Magic Eight Ball allows you to ask questions and receive one of several random answers). In order to complete this, you will need a couple of new functions. First, in order to get a line of input that can contain spaces, you cannot use cin, but instead will use getline: string question; cout <<...

  • Can you help me on this programming homework? Can you do same like this? Just do...

    Can you help me on this programming homework? Can you do same like this? Just do the basic java...for FOR,WHILE and DO-WHILE LOOP. I attached the problem... thank you actor Navigate Search Project Win package csci2e73 public class repetition public static void stringti arss) TODO Auto-Benerated method stub int result for (int i 51 i 10e: i i s) result result iu System-out printf Tsun is result): System-out printf Vnsum frem method calli sum(100) public static int sus (int n)...

  • Document2 Tell me ign Layout References Mailings Review View 1. Write a program called Lab18C that...

    Document2 Tell me ign Layout References Mailings Review View 1. Write a program called Lab18C that searches for a number in an array. T a. Write a bool function named search that receives 3 parameters: an int array, an int containing the length of the array, and an int number to search for. Return true if the number is in the array and false otherwise. b. Write a void function called fillArray with the array as a parameter that uses...

  • I need help making this work correctly. I'm trying to do an array but it is...

    I need help making this work correctly. I'm trying to do an array but it is drawing from a safeInput class that I am supposed to use from a previous lab. The safeInput class is located at the bottom of this question I'm stuck and it is not printing the output correctly. The three parts I think I am having most trouble with are in Bold below. Thanks in advance. Here are the parameters: Create a netbeans project called ArrayStuff...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT