home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / qc_prog / chap16 / mathtest.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-04-07  |  541 b   |  27 lines

  1. /* mathtest.c -- driver for do_math()                 */
  2. /* Program list: mathtest.c (to link math functions)  */
  3.  
  4. #include <stdio.h>
  5. double do_math(double);
  6. main()
  7. {
  8.     double input, result;
  9.  
  10.     printf("Enter a number: ");
  11.     while (scanf("%lf", &input) == 1)
  12.     {
  13.         result = do_math(input);
  14.         printf("input = %.2e, result = %.2e\n", input,
  15.                 result);
  16.         printf("Next number (q to quit): ");
  17.     }
  18. }
  19.  
  20. #include <math.h>
  21. double do_math(x)
  22. double x;
  23. {
  24.     return (sin (x) * exp (-x));
  25. }
  26.  
  27.