-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstaticmathclass.cpp
More file actions
34 lines (34 loc) · 831 Bytes
/
Copy pathstaticmathclass.cpp
File metadata and controls
34 lines (34 loc) · 831 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
31
32
33
34
// Implement a class Math with a static function members for basic arithmetic operation:
#include <iostream>
using namespace std;
class Math
{
public:
static int add(int a, int b)
{
return a + b;
}
static int sub(int a, int b)
{
return a - b;
}
static float division(float a, float b)
{
return a / b;
}
static double multiply(int a, int b)
{
return a * b;
}
};
int main()
{
int a,b;
cout<<"Enter two numbers for arithmetic operation:"<<endl;
cin>>a>>b;
cout << "addition is: " << Math::add(a,b)<< endl;
cout << "subtraction is: " << Math::sub(a,b) << endl;
cout << "Division is: " << Math::division(a,b) << endl;
cout << "Multiplication is: " << Math::multiply(a,b) << endl;
return 0;
}