Skip to main content

Posts

Showing posts with the label calculate average temperature of the week

Write a program in C++ to declare an array of size 7 that holds average temperature of the day for a week, calculate average temperature of the week, maximum and minimum temperature.

 Here's a C++ program to declare an array of size 7 that holds average temperature of the day for a week, calculate the average temperature of the week, maximum and minimum temperature: #include <iostream> using namespace std; int main() {     const int SIZE = 7;     double temperatures[SIZE];     // Prompt user to enter temperatures for each day     cout << "Enter average temperature for each day of the week: " << endl;     for (int i = 0; i < SIZE; i++) {         cout << "Day " << i+1 << ": ";         cin >> temperatures[i];     }     // Compute average temperature for the week     double sum = 0;     for (int i = 0; i < SIZE; i++) {         sum += temperatures[i];     }     double average = sum / SIZE;     // Find the maximum and minimum temperature ...