Calculate Percentage of Marks of 5 Subjects
Here you will know and get the example code to create a C++ Program to Calculate Percentage of Marks of 5 Subjects.
Example to Calculate Percentage of Marks of 5 Subjects
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | #include <iostream> using namespace std; int main() { float sub1, sub2, sub3, sub4, sub5; // Input marks cout << "Enter marks of 5 subjects: "; cin >> sub1 >> sub2 >> sub3 >> sub4 >> sub5; // find total marks float total = sub1 + sub2 + sub3 + sub4 + sub5; // find percentage float Percentage = (total / 500) * 100; float Average = total / 5; // print result cout << "\nPercentage: " << Percentage << "%"; cout << "\nAverage : " << Average; return 0; } |
Output
Enter marks of 5 subjects: 89
67
80
93
78
Percentage: 81.4%
Average : 81.4
Check out our other C++ programming Examples