Question: C + + , Array scoresArray has NUM _ SCORES numbers read from input. Array halfArray has half the size of scoresArray. Write a loop

C++,Array scoresArray has NUM_SCORES numbers read from input. Array halfArray has half the size of scoresArray. Write a loop that iterates through halfArray and:
If the corresponding element in the first half of scoresArray is less than 55.0, then assign the element in halfArray with 0.0.
Otherwise, assign the element in halfArray with the corresponding element in the first half of scoresArray.
Ex: If the input is:
65.055.050.032.560.072.5
then the output is:
Original scores: 65.055.050.032.560.072.5 Updated first half: 65.055.00.0
#include
#include
using namespace std;
int main(){
const int NUM_SCORES =6;
double scoresArray[NUM_SCORES];
double halfArray[NUM_SCORES /2];
int i;
for (i =0; i < NUM_SCORES; ++i){
cin >> scoresArray[i];
}
/* Your code goes here */
cout << "Original scores: ";
for (i =0; i < NUM_SCORES; ++i){
cout << fixed << setprecision(1)<< scoresArray[i]<<"";
}
cout << endl;
cout << "Updated first half: ";
for (i =0; i < NUM_SCORES /2; ++i){
cout << fixed << setprecision(1)<< halfArray[i]<<"";
}
cout << endl;
return 0;
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!