****.exe has encountered a problem...

i'm new at c++. i don't know what to do with my program. it keeps on having this problem "exerdraft.exe has encountered a problem and needs to be closed." i don't know what to do with it~

thanks~

here's a part of the program:

#include<iostream>

using namespace std;

void subj_ver();

main()
{
subj_ver();
system("pause");
}

void subj_ver()
{
double grade[]={0}; int x=1;
for(int subj=0;subj<3;subj++)
{
cout << "Subject " << x << ": ";
cin >> grade[subj];
cout << endl;
x++;
}

x=1;
for(int ver=0;ver<3;ver++)
{
cout << "Subject " << x << ": ";
if(grade[ver]<75)
cout << "FAILED.\n";
else
cout << "PASSED!\n";
x++;
}
}

the array size of grade is 1, because you initialize it with only one value, 0
youre accessing grades 0, 1, 2 and 3 in your loop

That wont work


just make grade size 4, double grade[4];
Last edited on
thanks!
Topic archived. No new replies allowed.