-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathComplexAddition.cpp
More file actions
44 lines (42 loc) · 1013 Bytes
/
ComplexAddition.cpp
File metadata and controls
44 lines (42 loc) · 1013 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
#include<iostream>
using namespace std;
class complex
{
private:
int real;
int imag;
public:
int input_val()
{
cout<<"Enter the values of real and the imaginary part"<<endl;
cin>>real>>imag;
}
int output_val()
{
cout<<"Entered the value of real and imaginary part"<<endl;
cout<<real;
cout<<" + ";
cout<<"i"<<imag<<endl;
}
complex add (complex c1, complex c2)
{
complex c3;
c3.real=c1.real+c2.real;
c3.imag=c1.imag+c2.imag;
cout<<endl<<endl;
cout<<"The Sum of The Complex Numbers is equal to"<<endl;
cout<<c3.real;
cout<<" + ";
cout<<"i"<<c3.imag;
}
};
int main()
{
complex c1,c2,c3;
c1.input_val();
c2.input_val();
c1.output_val();
c2.output_val();
c3.add(c1,c2);
return 0;
}