/* Square a complex number */ #include void squareComplex(double *aPtr, double *bPtr) { double a, b, aAns, bAns; // Retrieve a and b from the pointers a = *aPtr; b = *bPtr; // Compute the real and imaginary parts of answer aAns = (a*a) - (b*b); bAns = 2*a*b; // Return the answer via the pointers *aPtr = aAns; *bPtr = bAns; } void main() { double a = 4.0, b = 1.5; squareComplex(&a, &b); cout << "Answer: (" << a << " + " << b << "i)" << endl; }