/* include the standard I/O function prototypes */ #include /* define a structure for complex numbers, * and make it a type */ typedef struct Complex_s { double im, re; } Complex; static Complex product_Complex( Complex a, Complex b ) { Complex prod; prod.re = a.re * b.re - a.im * b.im; prod.im = a.re * b.im + a.im * b.re; return prod; } static void print_Complex( Complex z ) { printf( "( %f, %f )", z.im, z.re ); } int main() { /* declare and initialize two 3D points */ Complex x = { 1.0, 2.0 }, y = { 1.0, 1.0 }; Complex z = product_Complex( x, y ); printf( "product: " ); print_Complex( z ); printf( "\n" ); return 0; }