So I created a program where a user would input how many students to calculate their quiz scores and asks the user for 3 quiz scores and sum it all up. I currently have it all working except for taking the sum of the quiz scores in which on the first loop it has a large value. (See image below)
And here is my code:
#include <iostream>
#include <conio.h>
using namespace std;
int main() {
int count;
string student[100];
cout<<"How many students do you want to calculate for? ";
cin>>count;
cin.ignore();
int grades[count][3];
for (int i = 0; i<count; i++) {
cout<<"Enter Student Name: ";
getline (cin, student[i]);
cout<<"Enter quiz scores: ";
for (int a = 0; a<3; a++) {
cin>>grades[i][a];
}
cin.ignore();
}
int sum[count], sum2[count];
for (int i = 0; i<count; i++) {
for (int a = 0; a<3; a++) {
sum[i] = grades[i][a];
sum2[i] = sum2[i] + sum[i];
}
}
cout<<"\n";
for (int i = 0; i<count; i++) {
cout<<"\nStudent Name: "<<student[i]<<" | Quiz Scores: ";
for(int a = 0; a<3; a++) {
cout<<grades[i][a]<<" ";
}
cout<<"| Sum of grades: "<<sum2[i];
}
}