1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Daniel [21]
3 years ago
11

Write a for loop that sets each array element in bonusScores to the sum of itself and the next element, except for the last elem

ent which stays the same. Be careful not to index beyond the last element. Ex: If bonusScores = [10, 20, 30, 40], then after the loop bonusScores = [30, 50, 70, 40] The first element is 30 or 10 + 20, the second element is 50 or 20 + 30, and the third element is 70 or 30 + 40. The last element remains the same. function bonusScores = CombineScores(numberScores, userScores) % numberScores: Number of scores in array bonusScores % bonusScores: User defined array of test scores % Write a for loop that sets each array element in bonusScores to % the sum of itself and the next element, except for the last element % which stays the same bonusScores = userScores; end Code to call your function when you click Run
Computers and Technology
1 answer:
Nat2105 [25]3 years ago
3 0

Answer:

The program to this question can be given as:

Program:

#include<stdio.h>  //header file.

int main()

 //main function

{

   int SCORES_SIZE = 4;  //define variables.

   int bonusScores[]={10,20,30,40};  //define array.

   int i;

   printf("Values:");

 //message

   for (i = 0; i < SCORES_SIZE; ++i)  //loop for print values.

   {

       printf("%d ", bonusScores[i]);

   }

void CombineScores(int numberScore, int userScore) //function

{

   for (i = 0; i < SCORES_SIZE; i++)

  //loop for convert values

   {

       if (( bonusScores[i] <= bonusScores[i +1] ) || (bonusScores[i] < bonusScores [i+1]))  //check array elements

       {

           bonusScores[i] = (bonusScores [i] + bonusScores[i+1]);

 //add values

       }

       else

       {

           bonusScores[i] = bonusScores[i];

       }

   }

   printf("\nReturn values:");  //message

 for (i = 0; i < SCORES_SIZE; i++)

{

printf("%d",bonusScores[i]);

}

}

CombineScores(0,0); //calling

return 0;

}  

Output:

Values:10 20 30 40  

Return values:30 50 70 40  

Explanation:

In the above c++ programming code firstly we define the header file. Then we define the main function in this function we define variable that name is given in the question that is SCORES_SIZE, i. Variable i is used in the loop for a print array. Then we define and initialize an array. The array name is and elements are define in the question that is bonusScores[]={10,20,30,40}. Then we use the loop for print array elements.Then we define function that is CombineScores() in this we pass two parameter. Then we use the second time in this loop we check array elements and add the elements that are given in the question. In this function we print values and at the end we call function.

You might be interested in
Question 12 (1 point)
QveST [7]

Answer:

margins

Explanation:

the definition margins are the edges

8 0
3 years ago
The following checksum formula is widely used by banks and credit card companies to validate legal account numbers: d0 + f(d1) +
Aleksandr [31]

Answer:

Here is the JAVA program:

import java.util.Scanner; //to import Scanner class

public class ISBN

{   public static void main(String[] args)  { // start of main() function body

   Scanner s = new Scanner(System.in); // creates Scanner object

//prompts the user to enter 10 digit integer

   System.out.println("Enter the digits of an ISBN as integer: ");    

   String number = s.next(); // reads the number from the user

   int sum = 0; // stores the sum of the digits

   for (int i = 2; i <= number.length(); i++) {

//loop starts and continues till the end of the number is reached by i

          sum += (i * number.charAt(i - 1) ); }

/*this statement multiplies each digit of the number with i and adds the value of sum to the product result and stores in the sum variable*/

          int remainder = (sum % 11);  // take mod of sum by 11 to get checksum  

   if (remainder == 10)

/*if remainder is equal to 10 adds X at the end of given isbn number as checksum value */

  { System.out.println("The ISBN number is " + number + "X"); }

  else

// displays input number with the checksum value computed

 {System.out.println("The ISBN number is " + number + remainder); }  }  }  

Explanation:

This program takes a 10-digit integer as a command line argument and uses Scanner class to accept input from the user.

The for loop has a variable i that starts from 2 and the loop terminates when the value of i exceeds 10 and this loop multiplies each digit of the input number with the i and this product is added and stored in variable sum. charAt() function is used to return a char value at i-1.

This is done in the following way: suppose d represents each digit:

sum=d1 * 1 + d2 * 2 + d3 * 3 + d4 * 4 + d5 * 5 + d6 * 6 + d7 * 7 + d8 * 8 + d9 * 9

Next the mod operator is used to get the remainder by dividing the value of sum with 11 in order to find the checksum and stores the result in remainder variable.

If the value of remainder is equal to 10 then use X for 10 and the output will be the 10 digits and the 11th digit checksum (last digit) is X.

If the value of remainder is not equal to 10, then it prints a valid 11-digit number with the given integer as its first 10 digits and the checksum computed by sum % 11 as the last digit.  

8 0
3 years ago
All digital devices use software programs to function. Software <br> BLANK create these programs.
yarga [219]
Application I think because software used to create a program is called application software I'm not entirely sure about that though
7 0
3 years ago
What is an occupation?​
LiRa [457]

Answer:

a job or profession.

4 0
3 years ago
What is a algorithm?
Basile [38]
A process or set of rules to be followed in calculations or other problem-solving operations, especially by a computer.
4 0
3 years ago
Read 2 more answers
Other questions:
  • How could the provisions in the new health reform bill improve access to care?
    14·1 answer
  • To remove an embedded chart, you should _____ it and press the DELETE key.
    14·2 answers
  • The ____ function sums the numbers in the specified range and then divides the sum by the number of cells with numeric values in
    14·1 answer
  • what type of clause must you always use with DEKETE or UPDATE to avoid inadvertently changing data elsewhere in the database​
    12·1 answer
  • When an interrogator speaks highly about how a crime was committed, hoping to get the suspect to brag about his or her involveme
    7·2 answers
  • Rewrite this if/else if code segment into a switch statement int num = 0; int a = 10, b = 20, c = 20, d = 30, x = 40; if (num &g
    13·1 answer
  • A score of 3 or better on the exam administered at the end of which type of course usually means that you will earn college cred
    6·1 answer
  • Users at UC need to be able to quickly create a Resource record from the Project record's Chatter feed How should the App Builde
    10·1 answer
  • Drag the tiles to the correct boxes to complete the pairs.
    13·1 answer
  • Write a program that (a) generates a vector with 20 random integer elements with integers between -29 and 30, (b) replaces all t
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!