Write C++ statements that do the following. Make sure to include comments in you
ID: 643317 • Letter: W
Question
Write C++ statements that do the following. Make sure to include comments in your program to point out which part of your program is an answer for the parts below:
a) Store the following information in a course (struct):
name: Programming I
callNum: 13452
credits: 3
grade: 'A'
b) In the array classList, initialize each gpa to 0.0.
c) Copy the information of the thirty-first component of the array classList into student.
d) Update the gpa of the tenth student in the array classList by adding 0.75 to its previous value.
Explanation / Answer
#include <iostream>
#include <string>
using namespace std;
// this is part A
struct course{
string name;
int callNum;
int credits;
char grade;
};
int main(){
int size;
cout << "Number of students: ";
cin >> size;
double *classList = new double[size];
// this is part b
for(int i = 0; i < size; ++i){
classList[i] = 0.0;
}
// this is part c
if(size > 31){
int student = classList[31];
}
// this is part d
if(size > 10){
classList[10] += 0.75;
}
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.