1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
#include <iostream>
#include <cmath>
void deviation(double first, double second, double third, double fourth, double ave2);
void average(double first, double second, double third, double fourth, double ave1);
void average2(double first, double second, double third, double fourth, double ave1, double ave2);
using namespace std;
int main()
{
double first, second, third, fourth;
double ave1, ave2;
cout << "Enter four numbers." << endl; // lldb highlights this line of my code
cin >> first
>> second
>> third
>> fourth;
average(first, second, third, fourth, ave1);
average2(first, second, third, fourth, ave1, ave2);
deviation(first, second, third, fourth, ave2);
return 0;
}
void average(double first, double second, double third, double fourth, double ave1)
{
ave1 = (first + second + third + fourth) / 4;
}
void average2(double first, double second, double third, double fourth, double ave1, double ave2)
{
ave2 = (first - ave1) + (second - ave1) + (third - ave1) + (fourth - ave1);
}
void deviation(double first, double second, double third, double fourth, double ave2)
{
cout << sqrt(ave2);
}
|