1. Create a C++ program that let the user input his/here grade on the following subjects: Programming, Web Application, Oral Communication, Multimedia and Physics and calculate the average.
Note : the program must also display/output the subjects with grades from the user and the average.
#include<iostream>
#include<string>
using namespace std;
int main()
{
string arr[5] = { "Programming", "Web Application", "Oral Communication", "Multimedia", "Physics" };
char ch;
float sum = 0;
float arrgrd[5];
do
{
for (int i = 0; i < 5; i++)
{
cout << "Enter a grade for " << arr[i] << ": ";
cin >> arrgrd[i];
sum+= arrgrd[i];
}
for (int i = 0; i < 5; i++)
{
cout << "The grade for " << arr[i] << " is " << arrgrd[i] << endl;
}
cout << "The average is " << sum / 5;
cout << "\nDo you want to continue? [Y/N]: ";
cin >> ch;
sum = 0;
} while (ch == 'Y');
}
Comments
Leave a comment