-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
31 lines (26 loc) · 819 Bytes
/
main.cpp
File metadata and controls
31 lines (26 loc) · 819 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
#include <iostream>
#include <complex>
using namespace std;
int main() {
// Create complex numbers
complex<double> c1(3.0, 4.0);
complex<double> c2(1.0, 2.0);
complex<double> c3(0, -INFINITY);
// Display complex numbers
cout << "c1 = " << c1 << endl;
cout << "c2 = " << c2 << endl;
cout << "c3 = " << c3 << endl;
// Perform arithmetic operations
complex<double> c4 = c1 + c2;
complex<double> c5 = c1 - c2;
complex<double> c6 = c1 * c2;
complex<double> c7 = c1 / c2;
// Display results
cout << "c1 + c2 = " << c4 << endl;
cout << "c1 - c2 = " << c5 << endl;
cout << "c1 * c2 = " << c6 << endl;
cout << "c1 / c2 = " << c7 << endl;
// Calculate norm, conjugate, and projection
cout << "Norm of c1 = " << norm(c1) << endl;
return 0;
}