C Language and Libraries Help (clang.hlp) (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
CABS.C
                                             Up Contents Index Back
─────Run-Time Library───────────────────────────────────────────────────────
 
/* CABS.C illustrates functions:
 *      _cabs            _hypot
 */
 
#include <math.h>
#include <stdio.h>
 
void main()
{
    struct _complex ne = {  3.0,  4.0 }, se = { -3.0, -4.0 },
                   sw = { -3.0, -4.0 }, nw = { -3.0,  4.0 };
 
    printf( "Absolute %4.1lf + %4.1lfi:\t\t%4.1f\n",
            ne.x, ne.y, _cabs( ne ) );
    printf( "Absolute %4.1lf + %4.1lfi:\t\t%4.1f\n",
            sw.x, sw.y, _cabs( sw ) );
 
    printf( "Hypotenuse of %4.1lf and %4.1lf:\t%4.1f\n",
            se.x, se.y, _hypot( se.x, se.y ) );
    printf( "Hypotenuse of %4.1lf and %4.1lf:\t%4.1f\n",
            nw.x, nw.y, _hypot( nw.x, nw.y ) );
}
                                    -♦-