Assume the declarations of Exercise 10. Write C++ statements that do the followi
ID: 3910533 • Letter: A
Question
Assume the declarations of Exercise 10. Write C++ statements that do the following. (2, 3, 6,7, 8) a. Store the following information in course: name: Programming I callNum: 13452 credits: 3 grade:" b. In the array classList, initialize each gpa to 0.0 c Copy the information of the 31st component of the array classList into atudent. d. Update the gpa of the 10th student in the array classList by adding 0.75 to its previous value Declarations from Exercise 10 struct nameType struct courseTy stuct studentType string first; string last; atring name; int callNum int creditsi char grade; nameType name; double gpa; courseType course: 2: )i studentType student studentType classList [1001 courseType course; nameType name;Explanation / Answer
The required statements for the given questions are provided below. Please check and let me know if you have any doubts. Thanks.
//(a)
//assigning the required values to each field in course
course.name="Programming I";
course.callNum=13452;
course.credits=3;
course.grade=' ';
//(b)
//looping for 100 times (size of classList array)
for(int i=0;i<100;i++){
//setting gpa to 0.0
classList[i].gpa=0.0;
}
//(c)
//copying 31st element in classList to student.
//note that as array indices start from 0, 31st element will have
//the index 30
student=classList[30];
//(d)
//adding 0.75 to the gpa of 10th student in classList
//here also, as the indices start from 0, index 9 points to 10th element
classList[9].gpa+=0.75;
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.