jew work
By: jews | Date: Nov 17 2006 18:10 | Format: C++ | Expires: never | Size: 1.4 KB | Hits: 1449
- #include <cstdlib>
- #include <iostream>
- #include <cmath>
- #include <iomanip>
- using namespace std;
- void obtain(double[], int);
- double find_average(double[], int);
- double getHighest(double[], int);
- int main()
- {
- const int NUM_DAYS = 28;
- double temp[NUM_DAYS];
- double average, highest;
- obtain(temp, NUM_DAYS);
- average = find_average(temp, NUM_DAYS);
- highest = getHighest(temp, NUM_DAYS);
- cout << fixed << showpoint << setprecision(1);
- cout<<"average = " << average;
- cout<<"nhighest = "<< highest;
- system("PAUSE");
- return 0;
- }
- void obtain(double temp[], int NUM_DAYS)
- {
- for (int count = 0; count < NUM_DAYS; count++)
- {
- cout << "Enter the temp for each day ";
- cout << (count + 1) << ": ";
- cin >> temp[count];
- }
- }
- double find_average(double array[], int size)
- {
- double total = 0;
- for (int count = 0; count < size; count++)
- total += array[count];
- return total / size;
- }
- double getHighest(double array[], int size)
- {
- double highest;
- highest = array[0];
- for (int count = 1;count < size;count++)
- {
- if (array[count] > highest)
- highest = array[count];
- }
- return highest;
- }
Latest pastes
1 hours ago
11 hours ago
1 days ago
2 days ago
2 days ago