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

  1.  
  2. /* INFLATE.C -- shows multiple initialization */
  3. /*              and calculations in for loop  */
  4.  
  5. main()
  6. {
  7.     int year;
  8.     float value, rate;
  9.     printf("What do you think the inflation rate will be?");
  10.     scanf("%f", &rate);
  11.     printf("If the dollar is worth 100 cents in 1987\n");
  12.     printf("and the inflation rate is %2.2f, then:\n", rate);
  13.  
  14.     for (year=1988, value = 1.0; year <=1999;
  15.          value *= (1.0 - rate),
  16.          printf("in %d the dollar will be worth", year),
  17.          printf(" %2.0f cents\n", value * 100),
  18.          ++year
  19.          );
  20. }
  21.  
  22.