Please don't use eof() as the condition in a while loop.
In this case, it leads to loss of data depending upon whether or not there is any whitespace after the last value.
Do this instead:
1 2 3 4
while (fin >> num)
{
// do stuff with num
}
As for the specific question, the calculations are not correct.
Look at line 110:
stdDevNumerator += (num-avg) * (num-avg);
And what is the value of avg? Look at line 93:
total=0, avg = 0;
Aren't you supposed to be using the average obtained from the first pass, in the processing of the second pass?
That version is somewhat worse than the previous version. You still have avg=0; at line 92. That is the cause of the problem.
And to make matters worse, you removed the code stdDevNumerator += (num-avg) * (num-avg);
from where it belonged, inside the loop, and instead tried to do it afterwards.
I believe the problem you are working on requires the formula:
sqrt( (x1-m)2 + (x2-m)2 + (x3-m)2 + ... + (xn-m)2) / N )
where m is the mean and N is the number of values.
Here, m must be known before you start, and (x-m)2 must be done individually for each value.