I have a couple of easy questions, but I'm not that good at C++ yet, so I need your assistance...
I'm using an array to store for:
1) Test grades
2) Project grades
3) Lab grades
I want it to print out like this:
Test Scores: 92 73 81
My program runs, but this is what I'm getting for my results:
Example:
Test Scores: 92
Lab Scores: 58
Project Scores: 32
Test Scores: 77
Lab Scores: 65
Project Scores: 25
It doesn't print out the last scores that I input for (Test, Project, and Labs)...It only print out 2 of each...but not 3 of each (numofgrades = 3)
1) How do I make it finish printing out 3 of each and not just 2 of each
2) How do I make it into the format Test: 92 99 63 etc.
Thanks..
Here is my C++ code:
#include <iostream>
#include <iomanip>
using namespace std;
const int numofgrades = 3;
void testgrades(int testscores[]);
void labgrades(int labscores[]);
void projectgrades(int projectscores[]);
void printresults(int testscores[],int labscores[],int projectscores[]);
int main ()
{
cout<<fixed<<showpoint;
cout.precision(2);
int testscores[numofgrades];
int labscores[numofgrades];
int projectscores[numofgrades];
testgrades(testscores);
labgrades(labscores);
projectgrades(projectscores);
printresults(testscores,labscores,projectscores);
system ("PAUSE");
return 0;
}
void testgrades (int testscores[])
{
for (int i=1; i<=numofgrades; i++)
{
cout<<"Enter score for test #"<<i<<endl;
cin>>testscores[i];
}
}
void labgrades (int labscores[])
{
for (int i=1; i<=numofgrades; i++)
{
cout<<"Enter score for lab #"<<i<<endl;
cin>>labscores[i];
}
}
void projectgrades (int projectscores[])
{
for (int i=1; i<=numofgrades; i++)
{
cout<<"Enter score for project #"<<i<<endl;
cin>>projectscores[i];
}
}
void printresults(int testscores[],int labscores[],int projectscores[])
{
for (int i=1; i<numofgrades; i++)
{
cout<<"Test Scores: "<<testscores[i]<<endl;
cout<<"Lab Scores: "<<labscores[i]<<endl;
cout<<"Project Scores: "<<projectscores[i]<<endl;
}
}