I think using vectors instead of arrays will be better in this situation.

Because you don't know the size of the list and count it while reading it, vectors will be much simpler to deal with than arrays.

And, from your code .. I think you assume 999 to be the last of the numbers, you break there.

So .. I have modified your code to this ::
Code: CPP
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <fstream>

using namespace std;

int sizeofVector;
double findAvg(vector<int>);
double stdDev(vector<int>);

int main()
{
    double average, sDev;
    vector<int> values;
    int temp;

    ifstream infile;
    infile.open("c:\\test.txt");
    infile >> temp;

    while(temp != 999)
    {
        values.push_back(temp);
        infile >> temp;
    }
    sizeofVector=values.size();

    cout << "The average of the numbers is " << setw(5) << setprecision(3) << findAvg(values) << endl;
    cout << "The standard deviation of the numbers is " << setw(5) << setprecision(3) << stdDev(values) << endl;

    return 0;
}
double findAvg(vector<int> K)
{
    double sumnums = 0.0;
    for(int i = 0; i < sizeofVector; ++i)
        sumnums +=K[i];
    return sumnums/sizeofVector;
}
double stdDev(vector<int> K)
{
    double sumdevs = 0.0;
    double av=findAvg(K);
    for (int i = 0; i < sizeofVector; i++)
        sumdevs +=  pow((K[i] - av),2);
    return sqrt(sumdevs/sizeofVector);
}

I hope that will be useful.

Offtopic comment:
(*) Please post your code within [code]...[/code]
(*) Please *always* post properly indented code, makes things easier for us.

Last edited by SaswatPadhi; 27Dec2009 at 19:03..