Tuesday, 3 July 2018

c++ full online course problems with solution

Write a program that prompts the user to enter five test scores and then prints
the average test score


/////////solutions:///////////////



#include <iostream>
using namespace std;

int main() {

float  a,b,c,d,e;
float avg;
cout<<"Enter the score of first match"<<endl;
cin>>a;
cout<<"Enter the score of second match"<<endl;
cin>>b;
cout<<"Enter the score of third match"<<endl;
cin>>c;
cout<<"Enter the score of forth match"<<endl;
cin>>d;
cout<<"Enter the score of fifth match"<<endl;
cin>>e;
avg=(a+b+c+d+e)/(4+1);
cout<<"The average is "<<avg<<endl;
}

No comments:

Post a Comment