write a program jn c++ to read three numbers and compute their average?
Answers
C++ Program to Find Average of Three Numbers
Start.
Read first number to num_1.
Read second number to num_2.
Read third number to num_3.
Initialize average with (num_1 + num_2 + num_3) /3.
Stop.
MARK AS BRAINLIST
#include<iostream>
using namespace std;
double add(double num1, double num2, double num3);
double avg(double sum, int n);
int main()
{
double num1, num2, num3;
double sum, average;
cout << "Enter three Numbers :: ";
cin >> num1 >> num2 >> num3;
sum = add(num1 , num2, num3);
average = avg(sum, 3);
cout << "Sum = " << sum << endl;
cout << "Average = " << average << endl;
return 0;
}
double add(double num1, double num2, double num3)
{
return num1+num2+num3;
}
double avg(double sum, int n)
{
return sum / n;
}