78.8k views
3 votes
Populate a one-dimensional array with the following grades in this order: 90, 61, 74, 42, 83, 51, 71, 83, 98, 87, 94, 68, 44, and 66. Use a loop to call a method from main() that adds 15 points to all student grades that are a C or above. A C is defined as a score of 70 or above. Make this happen by passing the subscript value and not the entire array. The addition of the 15 points should happen in the method and be passed back to main. Use a loop to show final values within the array. The final array values should show the new adjusted grades.

User Meaghann
by
5.0k points

1 Answer

4 votes

Answer:

#include <iostream>

using namespace std;

void func(int&num)

{

if(num>=70)

num+=15;

}

int main()

{

int arr[]={90, 61, 74, 42, 83, 51, 71, 83, 98, 87, 94, 68, 44, 66};

for(int i=0;i<14;i++)

{

func(arr[i]);

}

cout<<"Adjusted scores are: ";

for(int i=0;i<14;i++)

{

cout<<arr[i]<<" ";

}

cout<<endl;

return 0;

}

Step-by-step explanation:

Our program is a one-dimensional array with the following grades in this order: 90, 61, 74, 42, 83, 51, 71, 83, 98, 87, 94, 68, 44, and 66.

It made use of loop to call a method from main() that adds 15 points to all student grades that are a C or above. A C is defined as a score of 70 or above.

It further uses a loop to show final values within the array. The final array values show the new adjusted grades.

User Bert Blommers
by
5.8k points