So basically, I'm new to programming and can't figure it out how to add certain numbers generated by the user. I want a program, capable of collecting for n days the temperature, and at the end, inform what the peak heat occurred, as well as the average of the temperatures collected.
#include <iostream>
using namespace std;
int main()
{
int days, day0 = 0, degrees, degrees_max = 0;
float degrees_average;
cout << "Days of the study" << endl;
cin >> days;
while (days > day0)
{
cout << "How many Degrees?" << endl;
cin >> degrees;
if (degrees < 999)
{
day0++;
}
if (degrees > degrees_max)
{
degrees_max = degrees;
}
}
degrees_average = degrees / days;
cout << "The max temperature was: " << degrees_max << "C"
<< " And the average was : " << degrees_average << endl;
}
SO the only thing left is how to calculate the average. All the help is appreciated! Thanks