I'm have serious trouble with this program. The average and the range do not work. The program runs...I just don't know how to fix this. Please help.

I have to find the average and the range of an unlimited number of integers between 0 and 100.

```
#include <iostream>
using namespace std;
int main ()
{
double num, sum=0, min1=0, max1=0, range, count=0;
cin >> num;
while (cin >> num)
{
++count;
if (num < 0 || num > 100)
{
cout << "out of range, value ignored" << endl;
}
else
{
for (min1 = num; num > 0; )
{
if (num < min1) min1 = num;
{
cin >> num;
}
}
for (max1 = num; num > 0; )
{
if (num > max1) max1 = num;
{
cin >> num;
}
}
sum += num;
range = max1 - min1;
}
}
cout << "The average is " << sum / count << endl;
cout << "The range is " << range << endl;
}
}
```