Write a program that will accept five (5) grades. Use an array in
storing the five (5) grades. Calculate the average of five (5) grades and
determine the remark of the average if PASSED or FAILED. Write a
function in accepting the five (5) grades, function in calculating the
average of the five (5) grades and a function in determining the remark of
the average.
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
//Implement a function wich return average
double Average(int a[5])
{
double sum=0.0;
for(int i=0;i<5;i++)
{
sum+=a[i];
}
return sum/5.0;
}
//return remark
const char*remark(double aver)
{
if(aver>=2.5)
return "PASSED";
else
return "FAILED";
}
int main() {
cout<<"Please input 5 marks\n";
int marks[5];
for(int i=0;i<5;i++)
cin>>marks[i];
double aver=Average(marks);
cout<<"Average of any marks: "<<aver<<endl;
cout<<"Resullts: "<<remark(aver)<<endl;
return 0;
}
Comments
Leave a comment