#include #include using namespace std; //Another simple structure, with only two members. struct complex_number { float real_part; float imag_part; }; //The following functions show how to accept a structure as an input argument //type. The first calculates the magnitude of a complex number: float Magnitude(complex_number z) { float magnitude = sqrt( pow(z.real_part,2) + pow(z.imag_part,2) ); return magnitude; }; //The second calculates the argument. float Argument(complex_number z) { float argument = atan2( z.imag_part,z.real_part ); argument *= 180.0 / M_PI; return argument; }; main() { complex_number z; z.real_part = 1.0; z.imag_part = 1.0; cout << "Magnitude is " << Magnitude(z) << endl; cout << "Argument is " << Argument(z) << endl; }