-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME.cpp
More file actions
51 lines (41 loc) · 1.64 KB
/
README.cpp
File metadata and controls
51 lines (41 loc) · 1.64 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# MPP-Lab-2
#include <iostream>
#include <algorithm>
#include <tuple>
using namespace std;
// Include necessary libraries
// Function to calculate the minimum, average, and maximum values
tuple<double, double, double> calculateStatistics(double num1, double num2, double num3) {
// Calculate the minimum value among three numbers
double min = std::min({ num1, num2, num3 });
// Calculate the maximum value among three numbers
double max = std::max({ num1, num2, num3 });
// Calculate the average value among three numbers
double avg = (num1 + num2 + num3) / 3.0;
// Return a tuple containing the minimum, average, and maximum values
return make_tuple(min, avg, max);
}
int main() {
double num1, num2, num3;
// Ask the user to enter the first number
cout << "Enter the first number: ";
// Read the first number from standard input
cin >> num1;
// Ask the user to enter the second number
cout << "Enter the second number: ";
// Read the second number from standard input
cin >> num2;
// Ask the user to enter the third number
cout << "Enter the third number: ";
// Read the third number from standard input
cin >> num3;
// Call the calculateStatistics function and get the results
auto result = calculateStatistics(num1, num2, num3);
// Output the minimum value to the screen
cout << "Min: " << get<0>(result) << endl;
// Output the average value to the screen
cout << "Average: " << get<1>(result) << endl;
// Output the maximum value to the screen
cout << "Max: " << get<2>(result) << endl;
return 0;
}