Tuesday, 3 July 2018

c++ simple project of match

Write a program that prompts the user to input five decimal numbers. The
program should then add the five decimal numbers, convert the sum to the
nearest integer, and print the result.
solution :



#include <iostream>
using namespace std;

int main() {

float  a,b,c,d,e;
int 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