COMP2113
COMP2113_ENGG1340 Programming technologies and Computer programming II [Section 2BC] [2023]
Loading...
Searching...
No Matches
meanSD.cpp File Reference
#include <iostream>
#include <cmath>
#include <iomanip>
Include dependency graph for meanSD.cpp:

Go to the source code of this file.

Functions

int main ()
 
double mean_5 (double a, double b, double c, double d, double e)
 
double sd_5 (double mean, double a, double b, double c, double d, double e)
 

Function Documentation

◆ main()

int main ( void )

Definition at line 15 of file meanSD.cpp.

15 {
16 double a,b,c,d,e,mean,sd = 0;
17 cin >> a >> b >> c >> d >> e;
18 mean = mean_5(a,b,c,d,e);
19 // set the number of decimal points to be printed
20 // uses #include <iomanip>
21 std::cout << std::fixed;
22 std::cout << std::setprecision(2);
23 // now it will print 1.23 instead of 1.23456789
24 cout << "Mean = " << mean << endl;
25 cout << "Standard deviation = " << sd_5(mean,a,b,c,d,e) << endl;
26 return 0;
27}
double mean_5(double a, double b, double c, double d, double e)
Definition meanSD.cpp:6
double sd_5(double mean, double a, double b, double c, double d, double e)
Definition meanSD.cpp:10

References mean_5(), and sd_5().

Here is the call graph for this function:

◆ mean_5()

double mean_5 ( double a,
double b,
double c,
double d,
double e )

Definition at line 6 of file meanSD.cpp.

6 {
7 return (a+b+c+d+e)/5;
8}

Referenced by main().

Here is the caller graph for this function:

◆ sd_5()

double sd_5 ( double mean,
double a,
double b,
double c,
double d,
double e )

Definition at line 10 of file meanSD.cpp.

10 {
11 return sqrt((pow(a-mean, 2)+pow(b-mean, 2)+pow(c-mean, 2)+pow(d-mean, 2)+pow(e-mean, 2))/5);
12}

Referenced by main().

Here is the caller graph for this function: