C++ Program For Calculate Percentage Of 5 Subjects

/* C++ Program to calculate Average of 5 subjects and find percentage  */
#include<iostream>
using namespace std;
int main()
{
        int mark[5], i;
        float sum=0;
        cout<<"\nEnter marks obtained in Physics, Chemistry, Maths, CS, English :: \n";
        for(i=0; i<5; i++)
        {
            cout<<"\nEnter mark[ "<<i+1<<" ] :: ";
                cin>>mark[i];
                sum=sum+mark[i];
        }
        float avg=sum/5;
        float perc;
        perc=(sum/500)*100;
        cout<<"\nAverage Marks of 5 Subjects = [ "<<avg<<" ] \n";
        cout<<"\nPercentage in 5 Subjects = [ "<<perc<<"% ] \n";
        return 0;
}

OUTPUT:

Enter marks obtained in Physics, Chemistry, Maths, CS, English ::
Enter mark[ 1 ] :: 79
Enter mark[ 2 ] :: 87
Enter mark[ 3 ] :: 67
Enter mark[ 4 ] :: 99
Enter mark[ 5 ] :: 80
Average Marks of 5 Subjects = [ 82.4 ]
Percentage in 5 Subjects = [ 82.4% ]
Process returned 0

Leave a Comment