Heya, I'm new too! The problem here is that every time the user enters the temperature, it gets written to Temp -- you are accidentally overwriting Temp every time.
Code:
for ( int i=0; i<=numCities; i++ )
{
cout <<"Enter the Temp: ";
cin >> Temp; // <---- right here
}
You're also going to have an extra city because of this:
Code:
for ( int i=0; i<=numCities; i++ )
If the user entered 1 city, the code would run once at i = 0, then again at i = 1 ...
Something like this would work better:
Code:
int totalTemp = 0;
for ( int i=0; i<numCities; i++ ) // i < numCities instead of <=, because it's starting at 0 instead of 1
{
cout <<"Enter the Temp: ";
cin >> Temp;
totalTemp = totalTemp + Temp;
}
averageTemp = totalTemp / numCities;
cout << "Average temp: " << averageTemp <<endl;