I started writing this code as practice for my Computer Science class. The goal was to help with structs and arrays. But I have come to a problem. The file will compile, but returns a message saying "floating point exception." Doing research I see there could a few reasons, but I can't stop any problems with my code. I was hoping if I had someone more experienced look at the code, maybe I can get help understanding what I did. BEWARE: I am just a beginner with C++. This may or may not hurt your eyes. Just some info on the program, it is suppose to open a file, read in the name and grade into a array, then calculate the average and find a curve. Then it is suppose to print out the new grades, with the curve added to it.

Here is the code:

``````#include <iostream>
#include <fstream>
#include <string>

using namespace std;

const int SIZE = 200;

{
string student;
};

int main()
{
int curve;
int i = 0;

curve = Curve(info, i);
for (int p = 0; p < i; p++)
{
cout << info[p].student << endl;
cout << info[p].grade + curve << endl;
}

return 0;
}

{

ifstream inFile;
string dud;

i = 0;
if (!inFile) return;

getline(inFile, info.student);

while (inFile && i < SIZE)
{
g[i] = info;
i++;

getline(inFile, dud);
getline(inFile, info.student);
}
inFile.close();
}

{
int avg, curve, i, data;
int sum = 0;
int count = 0;

for (i = 0; i < n; i++)
{
sum = sum + data;
count++;
}

avg = sum / count;

curve = 75 - avg;

return curve;
}
``````

Take a look at this function call

``curve = Curve(info, i);``

Your passing i = 0 and what do you think will happen in this function when n = 0?

``````int Curve(Grades g[], int n)
{
int avg, curve, i, data;
int sum = 0;
int count = 0;

for (i = 0; i < n; i++)//n = 0
{