Step 8: Defining the average(student st, int itemcount) method to calculate the average score of a selected student. The method alo starts by asking the user to input the id of the target student. This id is checked to make sure it really exist. The average score can be calculated by dividing the sum of quizz1 score, quizz2 score, assignment score, mid-term score, and final score by 5.
void average(struct student st, int itemcount)
int index = search(st, id,itemcount);
if (index != -1 && itemcount>0)
st[index].total = st[index].quizz1 + st[index].quizz2 + st[index].assigment + st[index].midterm + st[index].final;
avg = st[index].total /5;
cout<<"The average score is "<<avg;
This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages: