home *** CD-ROM | disk | FTP | other *** search
/ C Programming Starter Kit 2.0 / SamsPublishing-CProgrammingStarterKit-v2.0-Win31.iso / tyc / list19_1.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-10-16  |  467 b   |  25 lines

  1.  /* Demonstrate some math functions */
  2.  
  3.  #include <stdio.h>
  4.  #include <math.h>
  5.  
  6.  main()
  7.  {
  8.  
  9.      double x;
  10.  
  11.      printf("Enter a number: ");
  12.      scanf( "%lf", &x);
  13.  
  14.      printf("\n\nOriginal value: %lf", x);
  15.  
  16.      printf("\nCeil: %lf", ceil(x));
  17.      printf("\nFloor: %lf", floor(x));
  18.      if( x >= 0 )
  19.          printf("\nSquare root: %lf", sqrt(x) );
  20.      else
  21.         printf("\nNegative number" );
  22.  
  23.      printf("\nCosine: %lf", cos(x));
  24.  }
  25.