home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l353 / 1.img / EXAMPLES / MDB_GOOD.C < prev   
Encoding:
C/C++ Source or Header  |  1991-04-08  |  636 b   |  26 lines

  1. /* Program mdb_good.c */
  2.  
  3. #include <stdio.h>
  4. #include <math.h>
  5.  
  6. double foo(int *bar) {     /* Takes an int pointer,    */
  7.                            /*  returns a double.       */
  8.    double x;
  9.  
  10.    x = (double) (*bar)--;  /* Dereference pointer,     */
  11.                            /*  postdecrement value.    */
  12.  
  13.    return pow(2.0, x);     /* Return 2 to the x power. */
  14.    }
  15.  
  16. void main(void) {
  17.    int i = 10;             /* Initialize seed value.   */
  18.    double foo(int *bar);
  19.  
  20.    while(i)                      /* While i is not 0,  */
  21.       printf("%lf\n", foo(&i));  /*  print foo of i.   */
  22.  
  23.    return;
  24.    }
  25.  
  26.