Public paste
asdfasdfasdf
By: asdfasdf | Date: Nov 17 2006 18:03 | Format: C++ | Expires: never | Size: 1.3 KB | Hits: 1494

  1. #include <cstdlib>
  2. #include <iostream>
  3. #include <cmath>
  4. #include <iomanip>
  5. using namespace std;
  6.  
  7.  
  8. double find_average(double[], int);
  9. double getHighest(double[], int);
  10.  
  11.  
  12. int main()
  13. {
  14.      
  15.      const int NUM_DAYS = 28;
  16.      double temp[NUM_DAYS];
  17.      double total, average, highest;
  18.      
  19.      
  20.      for (int count = 0; count < NUM_DAYS; count++)
  21.      {
  22.          cout << "Enter the temp for each day ";
  23.          cout << (count + 1) << ": ";
  24.          cin >> temp[count];
  25.      }
  26.  
  27.      total = find_average(temp, NUM_DAYS);
  28.      
  29.      average = total / NUM_DAYS;
  30.      
  31.      highest = getHighest(temp, NUM_DAYS);
  32.      
  33.      cout << fixed << showpoint << setprecision(1);
  34.      cout<<"average = " << average;
  35.      cout<<"nhighest = "<< highest;
  36.      
  37.     system("PAUSE");
  38.     return 0;
  39. }
  40.  
  41.  
  42. double find_average(double array[], int size)
  43. {
  44.        double total = 0;
  45.        for (int count = 0; count < size; count++)
  46.        total += array[count];
  47.        return total;
  48.        
  49. }
  50.        
  51. double getHighest(double array[], int size)
  52. {
  53.        double highest;
  54.        
  55.        highest = array[0];
  56.        for (int count = 1;count < size;count++)
  57.        {
  58.            if (array[count] > highest)
  59.            highest = array[count];
  60.        }
  61.        
  62.        return highest;
  63.        }
  64.  
  65.