here's the part i'm having trouble with...i have read data from a file and stored it into 2 arrays. now i'm calc the average of the test....but i want to store the averages into a new array.
for(int i=0;i%26lt;STUDENTS;i++)
{
for(int j=0;j%26lt;TEST;j++)
{
inputFile %26gt;%26gt; testScores[i][j];
cout%26lt;%26lt;testScores[i][j]%26lt;%26lt;"\t";
}
inputFile%26gt;%26gt; StudentNames[i][1];
inputFile%26gt;%26gt; StudentNames[i][2];
cout%26lt;%26lt;StudentNames[i][1]%26lt;%26lt;" "%26lt;%26lt;left%26lt;%26lt;setw(15)%26lt;%26lt;StudentNames[i][2]%26lt;%26lt;"...
}
cout%26lt;%26lt;endl;
double avg, sum;
for(int row=0;row%26lt;STUDENTS;row++)
{
double sum=0;
for(int tnum=0; tnum%26lt;TEST; tnum++)
sum = sum + testScores[row][tnum];
avg = sum/TEST;
now to store these averages into a new array
C++ help...How do you store calculated values into a new array?
double avg, sum;
double averages[STUDENTS];
for(int row=0;row%26lt;STUDENTS;row++)
{
double sum=0;
for(int tnum=0; tnum%26lt;TEST; tnum++)
sum = sum + testScores[row][tnum];
avg = sum/TEST;
averages[row] = avg;
}
floral deliveries
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment