Noob needs help.
I have a situation where I'm asked to ask the user to enter in the number of cities to calculate an average temperature for and then use each of the 3 basic loop structures.
Now where I am is this. I ask the suer how many cities? Then I have a basic for loop wich is working. I can't seem to figure out how to get the program to add up all the temps to do the average. I am also not sure bout the variables.
I'm very new to this. Here is my code
Code:#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
//declare variables
int Temp = 0;
int averageTemp = 0;
int numCities = 0;
//double sum = 0; not sure?
cout << "Enter the number of cities you would to average: ";
cin >> numCities;
for ( int i=0; i<=numCities; i++ )
{
cout <<"Enter the Temp: ";
cin >> Temp;
}
//for ( int Temp=0; //this is where I'm stuck
//averageTemp = (temp + sum) /numCities;
cout << "Average temp: " << averageTemp <<endl;
system("pause");
return 0;