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.