Arithmetic/Complex: Difference between revisions

Content added Content deleted
(+ Pascal)
(→‎{{header|C++}}: The example didn't output)
Line 180: Line 180:
=={{header|C++}}==
=={{header|C++}}==
<cpp>
<cpp>
#include <iostream>
#include <complex>
#include <complex>
using std::complex;
using std::complex;
Line 186: Line 187:
complex<double> a(1.0, 1.0);
complex<double> a(1.0, 1.0);
complex<double> b(3.14159, 1.25);
complex<double> b(3.14159, 1.25);

complex<double> c;


// addition
// addition
c = a + b;
std::cout << a + b << std::endl;
// multiplication
// multiplication
c = a * b;
std::cout << a * b << std::endl;
// inversion
// inversion
c = 1.0 / a;
std::cout << 1.0 / a << std::endl;
// negation
// negation
c = -a;
std::cout << -a << std::endl;
}
}
</cpp>
</cpp>