|
# include <iostream.h>
# include <iomanip.h>
void pr_scores(float scores[ ]);
void calr_average(float, float scores,char s_name[ ]);
int main ( )
{
char s_name[ ] ="Tri star University";
float scores[6] = {54.6,48.6, 36.6,66.6,72.6, 78.6};
float average =0.0;
// call all function to print array.
pr_scores(scores);
void calr_average(float,scores, s_name);
return0;
}
void pr_scores (float scores[6])
{
int ctr ;
cout << "Here are your scores: ";
for (ctr=0;ctr<6; ctr++)
cout << setprecision(2) << scores[ctr] <<"\n";
return;
}
void calr_average(float acerage, float scores[6], char s_name[ ]);
{
int ctr;
// float * scores=scores;
// char * s_name = s_name; (要了这2个和没有这2个好像都一样亚)
for (ctr=0;ctr< 6;ctr++)
{
average += scores[ctr];
}
average /= float(6);
cout << "At" <<s_name<<", your class average is "<< setprecision(2) << average ;
return;
} |
|