HELPPPPPP

Hello,

i am doing a class in Problem Solving with C++ and am having difficulty with a problem. I have written the code but it is not building. I am using Microsoft Visual Studio. Please see the question and the code I have written:


The next assignment is:
Develop a solution that will caluculate the average temperature, given a set of temperatures. The number of temperatures may differ from time to time. (Use a trip value to stop the procession of the loop.) Test the solution with the following 10 temperatures:
78*
85*
87*
75*
56*
90*
80*
83*
90*
70*

Code

#include <iostream>
using namespace std;


void main()
{
int numberOftotalTemp=0;
int sum=0;
float average=0;
int Temp=0;

cout<< "Enter number of total temps";
cin>> numberOftotalTemp;

for(int Counter = 0; Counter < numberOftotalTemp; Counter = Counter + 1)
{
cout<< "Enter Temp";
cin>>Temp;
sum=sum+Temp;

}

average=sum/numberOftotalTemp;
cout<<endl<<"this is your average ";
cout<<average;

return;




}
When i try to build it in the compiler the dos screen appears where I can enter the necessary info but when I enter the last temperature it closes the screen down...
There's a whole sticky thread on this:

http://cplusplus.com/forum/beginner/1988/

What's happening is that you're reaching the end of the program. And when it reaches the end of the program, the program closes.

See that thread for solutions.
Topic archived. No new replies allowed.