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
Write a function MaxMagnitude with two input parameters, that returns the largest-magnitude value. If the inputs are 5 7, the fu
irakobra [83]

Answer:

The program to this question can be given as:

Program:

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

//#include<stdlib.h> //define header file  

#include<math.h> //define header file

int MaxMagnitude (int n1, int n2) //define function.

{

 int largest_magnitude_value= 0;

 if (abs(n1) > abs(n2))  

 {  

   // largest_magnitude_value

  largest_magnitude_value= n1;

 }

 else

 {  

   //largest_magnitude_value

   largest_magnitude_value=n2;

 }

 return largest_magnitude_value; //return value.

}

int main()  //define main function  

{

 int n1,n2,x;

 //define variable.

 printf("Enter first number :");

 //message

 scanf("%d",&n1);

 //input first value from user

 printf("Enter second number :");

//message

 scanf("%d",&n1);

    //input second value from user

 x=MaxMagnitude(n1, n2);  

//variable holds function return value

 printf("largest magnitude value  is =%d",x);

 //print value.

 return 0;

}

Output:

Enter first number : 5

Enter second number : 7

largest magnitude value is =7

Explanation:

The description of the above C program can be given as:

  • the above program firstly we define the header file in this we define the "math.h" header file that is a part of the "stdlib.h" that stands for standard library. This file includes math function, memory allocation, process control, and others.
  • Then we define a function that is "MaxMagnitude()" function.The return type of this function is int. I this function we pass two integer values that use the conditional statement to check which value is greater. In if block we use the absolute() function that returns an absolute value that holds in a variable that is "largest_magnitude_value".
  • Then we define the main function. In this, we define 3 integer variable that is n1,n2, and x. In the n1 and n2, we take value form the user and pass the value to the function in calling time and use x variable to print function return value.
6 0
3 years ago
Who said "BAM WHAT?!" On disney channel?
Yuki888 [10]
Maddie from Liv and Maddie 
4 0
3 years ago
Read 2 more answers
What does % find on edhesive??
statuscvo [17]

Answer:

Explanation: What is that word you typed?

3 0
3 years ago
The Zoom slider will allow users to _____.
NeX [460]
The Zoom slider will allow users to change the way the document appears on the screen
3 0
3 years ago
Read 2 more answers
What is the full form of ms-word?​
Alex

Answer:

microsoft word

Explanation:

i got certified on it sooooooooooo...

6 0
3 years ago
Read 2 more answers
Other questions:
  • o maintain reasonable key security (mark all that apply): Ensure that someone else always has an extra key. Ensure that no extra
    10·1 answer
  • Describe how an attacker can use whois databases and the nslookup tool to perform reconnaissance on an institution before launch
    8·1 answer
  • A small group of travelers is meeting inside an ancient building, and the travelers need access to the Internet using their mobi
    13·1 answer
  • Which is better computer science or software engineering?
    10·2 answers
  • Is number 1 correct​
    7·2 answers
  • Software licensed using the Open Software Initiative (OSI) definition
    5·2 answers
  • What is one advantage of using object-oriented programming?
    14·2 answers
  • Consider the relational schema below: Students(sid: integer, sname: string, major: string) Courses(cid: integer, cname: string,
    9·1 answer
  • A chip that wakes up the computer system
    10·1 answer
  • I know I'm asking for a lot. But this is my last question. If we do it I pass my semester. help please.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!