-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogram11.cpp
More file actions
58 lines (40 loc) · 1006 Bytes
/
program11.cpp
File metadata and controls
58 lines (40 loc) · 1006 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include<iostream>
using namespace std;
class complex
{
public:
int real;
int imaginary;
public: complex()
{
real=imaginary=0;
}
void addition(complex num_r, complex num_s )
{
real=num_r.real+num_s.real;
imaginary =num_r.imaginary+num_s.imaginary; cout<<"the resultant of the addition is\n:"
<<real<<"+("<<imaginary<<")i\n";
}
void subtraction(complex num_r, complex num_s)
{
real=num_r.real-num_s.real;
imaginary = num_r.imaginary-num_s.imaginary; cout<<"the resultant of the subtraction is: "
<<real<<"+("<<imaginary<<")i\n";
}
};
int main()
{
complex numr;
complex nums; complex output;
cout<<"enter the real part of the first complex number\n";
cin>>numr.real;
cout<<"enter the real part of the second complex number\n";
cin>>nums.real;
cout<<"enter the imaginary part of the first complex number\n";
cin>>numr.imaginary;
cout<<"enter the imaginary part of the second complex number\n";
cin>>nums.imaginary;
output.addition (numr, nums);
output.subtraction (numr, nums);
return 0;
}