I'm trying to run my program and when I enter say 3 it gives me a fatal error. It is suppose to calculate the avg of each value entered and output it. Would appreciate a little advise on this I'm stumped. The error says "warning C4700: uninitialized local variable 'sum' used".
I think I might haft to declare sum as an integer but that dosn't seem right if I want digits up to 2 decimal positions.
int main ()
{
double num, sum, average;
cout << "Enter a value -99 to end:";
cin >> num;
while (num != -99)
{
sum = sum + num;
average = sum/num;
cout << "The average is:" << setprecision (2) << (double)average << endl << endl;
cout << "Enter another value -99 to end:";
cin >> num;
}
return 0;
}