home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / c / other / learn / volume.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-10-07  |  389 b   |  24 lines

  1. /* VOLUME.C: Calculate sphere's volume. */
  2.  
  3. #include <stdio.h>
  4. #define PI 3.14
  5.  
  6. float sphere( int rad );
  7.  
  8. main()
  9. {
  10.    float volume;
  11.    int radius = 3;
  12.    volume = sphere( radius );
  13.    printf( "Volume: %f\n", volume );
  14. }
  15.  
  16. float sphere( int rad )
  17. {
  18.    float result;
  19.    result = rad * rad * rad;
  20.    result = 4 * PI * result;
  21.    result = result / 3;
  22.    return result;
  23. }
  24.