Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using C++(microsoft visual studios 2013) create a program with comments (//comme

ID: 3811925 • Letter: U

Question

Using C++(microsoft visual studios 2013) create a program with comments (//comments) using the following instructions:

Populate a one-dimensional array with the following grades in this order:

91, 62, 75, 43, 84, 52, 70, 84, 99, 88, 91, 69 and 67.

Use a loop to call a method from main() that adds 10 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 10 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.

Explanation / Answer

#include <iostream>
#include <cstdlib>   
#include <ctime>
using namespace std;
int add10(int grade){
return grade+10;
}
int main()
{
int grades[] = {91, 62, 75, 43, 84, 52, 70, 84, 99, 88, 91, 69, 67};
int n = 13;
for(int i=0; i<13; i++){
if(grades[i] >= 70){
grades[i] = add10(grades[i]);
}
}

cout<<"Arrays elements are: "<<endl;
for(int i=0; i<13; i++){
cout<<grades[i]<<" ";
  
}
cout<<endl;
return 0;
}

Output:

sh-4.2$ g++ -o main *.cpp                                                                                                                                                                                                                                                

sh-4.2$ main                                                                                                                                                                                                                                                             

Arrays elements are:                                                                                                                                                                                                                                                     

101 62 85 43 94 52 80 94 109 98 101 69 67

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote