So I've written out a program that is supposed to calculate my grades and give me a letter grade and total point score. However for some reason my getScore function keeps returning me junk (-2.5304.. etc). I know it has something to do with my arrays because when i exclude them it works as expected. Can anyone tell me what might be my problem?
Student Grades.h
#include <iostream>
#include <string>
using namespace std;
int main()
{
//const int numlabs=12;
//const int numdays=15;
double LABS[12];
double ATTENDANCE[15];
double MIDTERM;
double QUIZ;
double FINAL;
int i;
cout<<"Please enter the number of points"<<endl;
cout<<"you scored for each lab assignment."<<endl;
for (i=0;i<12;i++)
{
cout<<"Enter Lab "<<(i+1)<<"'s points"<<endl;
cin>>LABS[i];
}
cout<<endl;
cout<<"Please enter the number of points"<<endl;
cout<<"you scored for each day you attended class."<<endl;
for (i=0;i<15;i++)
{
cout<<"Enter number of points recieved on day "<<(i+1)<<endl;
cin>>ATTENDANCE[i];
}
cout<<endl;
cout<<"Please enter the number of points"<<endl;
cout<<"you earned in your quiz."<<endl;
cin>>QUIZ;
cout<<endl;
cout<<"Please enter the number of points"<<endl;
cout<<"you scored in your midterm."<<endl;
cin>>MIDTERM;
cout<<endl;
cout<<"Please enter the number of points"<<endl;
cout<<"you earned in your final."<<endl;
cin>>FINAL;
cout<<endl;
1. Both arrays have 7 elements. The valid indices are thus 0..6.
The foo[7] points to memory that is just beyond the block allocated for array foo.
An out of bounds error.
2. foo[k] deferences k'th element. foo[k] is one integer, not an array.
Are you trying to copy arrays? If yes:
1 2 3 4 5
const size_t N = 7;
int foo[N];
int bar[N];
std::copy_n( bar, N, foo );