struct not showing the right number

Hi, my struct : student[index].test is not showing the right result.
here is my code:

#include<iostream>
#include<string>
#include <iomanip>
using namespace std;

struct ClassGrade
{
int test;
double avgGrade;

};


int main()
{
const int size=3;
ClassGrade student[size];
int sum;

for(int index=0;index<size;index++)
{
cout<<"enter 3 test scores";
cin>>student[index].test;

sum+= student[index].test ;

}
cout<<sum;
return 0;
}
What is the value of the sum before the first iteration of the loop?
It shows 4201067, even if I try to initialize int sum=0;
oh fixed, I think my IDE has some issue, it says can not open the file. When I restart it, it runs fine
Topic archived. No new replies allowed.