Basically, you input a bunch of numbers, and end it with a negative number. It should output the standard deviation of that set of numbers. The problem is, that I keep getting I.#INF . What is that, and how do I fix my code to get the math right?

#include <iostream> #include <iomanip> #include <math.h> using namespace std; void main () { int pos, cnt; float avg, data[50], tot, num; cout.setf(ios::fixed); cout.precision(1); pos=0; cnt=0; cout << "Num? "; cin >> num; while (num >=0) { pos++; cnt++; data[pos]=num; cout << "Num? "; cin >> num; } tot=0; for (pos=0; pos<cnt-1; pos++) tot+=(data[pos+1]-data[pos])*(data[pos+1]-data[pos]); avg=tot/cnt; cout << "The standard deviation is " << sqrt(avg) << endl;

once I get this right, I'll integrate this code into my larger program.