home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / qc / qc25 / volume.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-11-15  |  387 b   |  23 lines

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