Write a program that asks the user the daily temperature at noon over the course of one month. Store the values in an array. At the end of the program, display the highest and lowest temperature, as well as the average temperature over the course of the month.
I tried finding the highest temperature using if/else but for some reason high is always the sum of the arrays. Any help will be greatly appreciated thanks alot in advance!
ps. replaced 30 with 3
#include <iostream>
using namespace std;
int main ()
{
int days[3],sum=0;
double avg;
double high;
cout<<"Enter noon temperatures for 3 days\n";
for (int a=0;a<3;a++)
{
cin>>days[a];
sum=sum+days[a];
if (days[a+1]>days[a])
high=days[a+1];
else
high=days[a];
}
avg=sum/3;
cout<<"The average temperature is"<<avg<<endl;
cout<<"The highest temperature is"<<high<<endl;
return 0;
}