home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / c / other / math / cabs.c next >
Encoding:
C/C++ Source or Header  |  1988-12-03  |  668 b   |  23 lines

  1. /* CABS.C illustrates functions:
  2.  *      cabs            hypot
  3.  */
  4.  
  5. #include <math.h>
  6. #include <stdio.h>
  7.  
  8. main()
  9. {
  10.     static struct complex ne = {  3.0,  4.0 }, se = { -3.0, -4.0 },
  11.                           sw = { -3.0, -4.0 }, nw = { -3.0,  4.0 };
  12.  
  13.     printf( "Absolute %4.1lf + %4.1lfi:\t\t%4.1f\n",
  14.             ne.x, ne.y, cabs( ne ) );
  15.     printf( "Absolute %4.1lf + %4.1lfi:\t\t%4.1f\n",
  16.             sw.x, sw.y, cabs( sw ) );
  17.  
  18.     printf( "Hypotenuse of %4.1lf and %4.1lf:\t%4.1f\n",
  19.             se.x, se.y, hypot( se.x, se.y ) );
  20.     printf( "Hypotenuse of %4.1lf and %4.1lf:\t%4.1f\n",
  21.             nw.x, nw.y, hypot( nw.x, nw.y ) );
  22. }
  23.