Lab2_Q3

Run Settings
LanguageC++
Language Version
Run Command
#include <iostream> using namespace std; struct complex{ double re; double im; complex(double a, double b){ re = a; im = b; } void add(complex b); void multiply(complex b); void conjugate(); void print(); }; void complex::print(){ cout << "real is " << re << " and imaginary is " << im << endl; } void complex::multiply(complex b){ int temp = re*b.re-im*b.im; im = im*b.re+re*b.im; re = temp; } void complex::add(complex b){ re += b.re; im += b.im; } void complex::conjugate(){ im = -im; } int main() { complex x={3,4}, y={1,-0.25}; x.print(); y.print(); x.add(y); x.print(); y.multiply(x); y.print(); x.conjugate(); x.print(); y.conjugate(); y.print(); return 0; }
Editor Settings
Theme
Key bindings
Full width
Lines