hi this program compile and run correctly but it gives wrong out put, please help..
// calculate the number of days with temp greater than 20 degrees.
#include <iostream>
using namespace std;
int main ()
{
int nrAbove ;
int temp ;
bool result;
nrAbove = 0;
temp = 0;
cout <<"Temperature of first day (-100 for end of input) : ";
cin >> temp;
while (temp > -100)
{
cout <<"Temperature of next day (-100 for end of input) : ";
cin >> temp;
result = temp > 20;
if (result)
temp += nrAbove;
nrAbove++;
}
cout << "Number of days with temperature above 20 degrees C is ";
cout << nrAbove << endl;
#include <iostream>
usingnamespace std;
int main ()
{
int nrAbove ;
int temp ;
bool result;
nrAbove = 0;
temp = 0;
cout <<"Temperature of first day (-100 for end of input) : ";
cin >> temp;
if (temp>20) nrAbove++;
while (temp > -100)
{
cout <<"Temperature of next day (-100 for end of input) : ";
cin >> temp;
result = temp > 20;
if (result) nrAbove++;
}
cout << "Number of days with temperature above 20 degrees C is ";
cout << nrAbove << endl;
return 0;
}