-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclass29.cpp
More file actions
30 lines (26 loc) · 767 Bytes
/
class29.cpp
File metadata and controls
30 lines (26 loc) · 767 Bytes
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
#include <iostream>
using namespace std;
int calculate(int a, int b){
return a+b;
}
float calculate(float a, float b){
return a+b;
}
float calculate(float a, float b, float c){
float sum = a + b + c;
return sum / 3;
}
int main(){
int int1, int2;
float float1, float2, float3;
cout << "Enter two integers: ";
cin >> int1 >> int2;
cout << "Sum of integers: " << calculate(int1, int2) << endl;
cout << "Enter two floats: ";
cin >> float1 >> float2;
cout << "Sum of floats: " << calculate(float1, float2) << endl;
cout << "Enter three floats: ";
cin >> float1 >> float2 >> float3;
cout << "Average of three floats: " << calculate(float1, float2, float3) << endl;
return 0;
}