I need help sorting it from lowest to highest but then on the left column still having it say which test it is
here is what I have so far. I am really new at c++ so if you could help me that would be awesome. =)
// compiler directives
#include <iostream>
#include<iomanip>
#include<stdio.h>
// main program
int main()
{
// local identifiers
int TestScores[MAXSIZE];
float Avg = 0;
//Input modale
GetData(TestScores);
//processing module
ComputeAvg(TestScores,Avg);
//output module
PrintReport(TestScores,Avg);
system ("PAUSE");
return 0 ;
}//end main
// function definitions
void GetData (int TestScores[ ])
{
for (int i=0; i <MAXSIZE; i++)
{
cout<<"please enter the test score #"<<i+1<<":\t";
cin>>TestScores[i];
}
return;
}
// end GetData
void ComputeAvg( int TestScoresf[],float&Avgf)
{
float sum = 0;
for(int i=0; i <MAXSIZE; i++)
{
sum = sum+ TestScoresf[i];
}
Avgf =(sum)/MAXSIZE;
return;
} //end ComputeAvg
void PrintReport (int TestScoresf[], float Avgf)
{
int temp;
for (int i = 0; i < MAXSIZE; i++)
{
for (int j = i + 1; j < MAXSIZE; j++)
{
if (TestScoresf[j] < TestScoresf[i])
{
temp = TestScoresf[i];
TestScoresf[i] = TestScoresf[j];
TestScoresf[j] = temp;
cout<<setw(23)<<"Test#"<<setw(15)<<"TestScore";
cout<<"\n\n";
for(int i = 0; i <MAXSIZE; i ++)
{
cout<<setw(26)<<i+1<<setw(20)<<TestScoresf[i]<<endl;
}
cout<<"\n\n"<<fixed<<showpoint<<setprecision(20);
cout<<"test score average:\t"<<Avgf<<endl;
}
// end print Report
void printsorted (int TestScoresf[]);
int temp;
for (int i = 0; i < MAXSIZE; i++)
{
for (int j = i + 1; j < MAXSIZE; j++)
{
if (TestScoresf[j] < TestScoresf[i])
{
temp = TestScoresf[i];
TestScoresf[i] = TestScoresf[j];
TestScoresf[j] = temp;
}
}
hey i am also a newbie but the first error i see here is using
void
and what do you expect it to return? i think void i being use only to print and return nothing but u ask for return and did'nt even declare what to return;