-remove the ' 30 ' in your code.
-swap lines: cin >> temp; and nrAbove++;
Thanks I was about to post the following.
“Sorry guys I when I run the program it work’s, when I try again it doesn’t, it sorts of freeze’s.“
Now it works better.
Complete code appears below.
// How many days with temperature above 20 degrees C?
#include <iostream>
using namespace std;
int main( )
{
float temp;
int nrAbove;
// initialize
nrAbove = 0;
cout << "Temperature of first day (-100 for end of input): ";
cin >> temp;
// loop
while (temp > -100)
{
if (temp > 20) // temperature above 20 degrees?
nrAbove++;
cin >> temp;
} // end of while loop
// results
cout << "Number of days with temperature above 20 degrees C is ";
cout << nrAbove << endl;
return 0;
}