Create an array of 7 words,named "temperatures"containing daily temperatures for a week. Temperatures can be positive or negative values. Write a program to count number of days of extreme temperature, that is, less than -10or greater than +25. You may allow the user to input the 7 temperatures, or hardcode it. But make sure that there are extreme temperatures. Display the number of days of extreme temperature

Respuesta :

Answer:

// program in C++.

// headres

#include <bits/stdc++.h>

using namespace std;

// main function

int main()

{

   // array

   int temperatures[7];

   // count variable

   int count=0;

   cout<<"Enter the temperature of all days:";

   for(int a=0;a<7;a++)

   {

       // read temperature of 7 days

       cin>>temperatures[a];

       // find temperature is extreme or not

       if(temperatures[a]<-10||temperatures[a]>25)

       // count

       count++;

   }

   // print count of extreme temperature

   cout<<"number of days of extreme temperature:"<<count<<endl;

return 0;

}

Explanation:

Create an array of size 7 to store the temperature of all days of week.Read the temperature of each day.If the temperature is less than -10 or greater than 25 then increment the count.This will count the number of days of extreme temperature.Print  the count.

Output:

Enter the temperature of all days:-20 12 18 30 32 -15 15                                                                  

number of days of extreme temperature:4