28. Program that inputs marks obtained by a student in five subjects. It then calulates and dispays the total marks and percentage.

Chapter 4: 

Input And Output

Programming Exercise

Problem # 28:

Write a program that inputs marks obtained by a student in five subjects. It then
calculates and displays the total marks and percentage.

Solution:

#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
    int m1, m2, m3, m4, m5, totalMarks;
    float percentage;
    cout<<"Enter marks of five subjects : ";
    cin>>m1>>m2>>m3>>m4>>m5;
    totalMarks = m1 + m2 + m3 + m4 + m5;
    cout<<"Total marks : "<<totalMarks<<endl;
    percentage = (totalMarks / 500.0) * 100.0;
    cout<<"Percentage : "<<percentage<<"%"<<endl;
    return 0;
}

Let me know in the comment section if you have any question.

Previous Post:
27. Program that displays the following output: Number Square Cube

Comments

Post a Comment