How on gods green earth are we meant to answer that?
My guess is that you have a bug in your program, possibly an infinite loop. Windows is not getting a timely response from your program, so tells you it has stopped working.
yeah there is a loop in input and output files, OK then how to limit the loop ?
here is my program .
// a program that reads a list of students marks from an input file and calculate
// average total marks and grades in an output file
#include<iostream>
#include<fstream>
#include<string>
#include<iomanip>
using namespace std;
int main()
{
float ID[10],homew[10],lap[10],final[10],total[10];
string grade[10];
int x=0, studentNum = 0; // initial value zero
float avgTotal;// total marks average
string avgGrade;// class average grade
outfile.open("results.dat");// open output file
if (!outfile)
{
cout << "Can't open the output file" << endl;//error message if output file does not exist
return 2;
}
while (outfile)
{
x++;
studentNum++;
total[x] = homew[x] + lap[x] + final[x];
if (total[x]<0 && total[x]>100)
cout << "total mark is not counted" << endl;
if (total[x]>=95&&total[x]<=100)
grade[x]="A";
else if (total[x]>=90&&total[x]<=95)
grade[x]= "A-";
else if (total[x]>=85&&total[x]<=89)
grade[x]= "B+";
else if (total[x]>=80&&total[x]<=84)
grade[x]="B";
else if (total[x]>=75&&total[x]<=79)
grade[x]="B-";
else if (total[x]>=70&&total[x]<=74)
grade[x]="C+";
else if (total[x]>=65&&total[x]<=69)
grade[x]="C";
else if (total[x]>=60&&total[x]<=64)
grade[x]="C-";
else if (total[x]>=55&&total[x]<=59)
grade[x]="D";
else if (total[x]<=55)
grade[x]="F";
avgTotal = total[studentNum]/studentNum; // class average of total marks
outfile << "The class average total mark and grade is: " << avgTotal << endl;
if ( avgTotal >= 80)
outfile << " High average" << endl;
else
outfile << "Normal average" << endl;
}//end of file
infile.close();// close input file
outfile.close();// close output file
Try using an if statement at the bottom in the int main() which will terminate the whole loop with a break if a certain value exceeds the number you want.