180k views
5 votes
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

User KBT
by
5.6k points

1 Answer

6 votes

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

// print count of extreme temperature

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

return 0;

}

Step-by-step 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

User Saram
by
5.7k points