-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path5_1.cpp
More file actions
64 lines (50 loc) · 1.49 KB
/
5_1.cpp
File metadata and controls
64 lines (50 loc) · 1.49 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
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <iostream>
#include <vector>
using namespace std;
class Calculator {
private:
vector<double> results;
public:
int add(int a, int b) {
int result = a + b;
results.push_back(result);
return result;
}
float add(float a, float b) {
float result = a + b;
results.push_back(result);
return result;
}
double add(double a, double b) {
double result = a + b;
results.push_back(result);
return result;
}
double add(int a, double b) {
double result = a + b;
results.push_back(result);
return result;
}
double add(double a, int b) {
double result = a + b;
results.push_back(result);
return result;
}
void displayResults() {
cout << "\nStored Results:\n";
for (size_t i = 0; i < results.size(); ++i) {
cout << "Result " << i + 1 << ": " << results[i] << endl;
}
}
};
int main() {
Calculator calc;
cout << "Adding int + int: " << calc.add(5, 3) << endl;
cout << "Adding float + float: " << calc.add(2.5f, 3.7f) << endl;
cout << "Adding double + double: " << calc.add(1.234, 5.678) << endl;
cout << "Adding int + double: " << calc.add(4, 2.75) << endl;
cout << "Adding double + int: " << calc.add(6.25, 3) << endl;
calc.displayResults();
cout<<endl<<"24CE052_pushti kansara"<<endl;
return 0;
}