-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcomplex.cpp
66 lines (60 loc) · 1.16 KB
/
complex.cpp
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
65
66
#include<iostream>
using namespace std;
void name(){
cout<<'Author: Varun Gupta'<<endl;
}
class Complex2;
class Complex
{
protected:
public:
int real,imag;
friend int Sum_Complex(Complex ,Complex,Complex2 ,Complex2 );
Complex()
{
cout<<"Enter the real part "<<endl;
cin>>real;
}
void Show()
{
cout<<"Real part "<<real<<endl;
}
};
class Complex2
{
protected:
int imag;
public:
friend int Sum_Complex(Complex ,Complex ,Complex2 ,Complex2 );
Complex2()
{
cout<<"Enter the imaginary part :"<<endl;
cin>>imag;
}
void show()
{
cout<<"imaginary part is :"<<imag<<"i"<<endl;
}
};
int Sum_Complex(Complex c1,Complex c2,Complex2 c3,Complex2 c4)
{
int o,o1;
o=(c1.real + c2.real);
o1=(c3.imag + c4.imag);
cout<<"Real part "<<o<<" + "<<o1<<" i "<<endl;
return 0;
}
int main(){
name();
int a1,a2;
int a;
Complex d1,d2;
d1.Show();
d2.Show();
Complex2 c1,c2;
c1.show();
c2.show();
// a= Sum_Complex(d12,c2);
cout<<Sum_Complex(d1,d2,c1,c2);
return 0;
}