home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / qc_prog / chap03 / avgtemp.c next >
Encoding:
C/C++ Source or Header  |  1988-04-06  |  809 b   |  31 lines

  1. /* avgtemp.c -- finds average temperature */
  2. /*              for the week              */
  3.  
  4. main()
  5. {
  6.     int t1, t2, t3, t4, t5, t6, t7;
  7.     float avg;
  8.  
  9.     printf("Enter the high temperature for:\n");
  10.     printf("Monday: ");
  11.     scanf("%d", &t1);
  12.     printf("Tuesday: ");
  13.     scanf("%d", &t2);
  14.     printf("Wednesday: ");
  15.     scanf("%d", &t3);
  16.     printf("Thursday: ");
  17.     scanf("%d", &t4);
  18.     printf("Friday: ");
  19.     scanf("%d", &t5);
  20.     printf("Saturday: ");
  21.     scanf("%d", &t6);
  22.     printf("Sunday: ");
  23.     scanf("%d", &t7);
  24.  
  25.     /* calculate and display average */
  26.     avg = (t1 + t2 + t3 + t4 + t5 + t6 + t7) / 7.0;
  27.           /* divide by 7.0 to ensure float result */
  28.     printf("The average high temperature for");
  29.     printf(" this week was %5.2f degrees.\n", avg);
  30. }
  31.