Kaloyankerr

School task

Apr 14th, 2022
1,480
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.   int days;
  6.   int avgTemperature;
  7.  
  8.   cout << "How many days are there in your month: ";
  9.   cin >> days;
  10.   cout << "What is the average temperature: ";
  11.   cin >> avgTemperature;
  12.  
  13.   int monthDays[days];
  14.   for (int i = 1; i <= days; i++) {
  15.    cout << "Enter the temperature for the " << i << " day: " << endl;
  16.    cin >> monthDays[i];
  17.   }
  18.  
  19.   int degreesCounter = 0;
  20.   for (int i = 1; i <= days; i++) {
  21.     if (monthDays[i] == avgTemperature) {
  22.         degreesCounter ++;
  23.     }
  24.   }
  25.  
  26.   cout << "The number of days with average temperature is: " << degreesCounter;
  27.   return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment