0

Im new to c++ and i'm tryin to compute the standard deviation of a set of floating point numbers using a data file. here I started my program and skip over things i didn't really know but can someone plaese help me.
****************************************************************************

#include<iostream>
#incluse<fstream>
#include <cstdlib>
#include <cmath>

int main()
{
using namespace std;
ifstream in_stream;
ofstream out_stream;


Right in here i need help into what i put in the middle statement

}

double next,sum = 0;
double average;
double s_dev = 0;
int count = 0;
while(in_stream >> next)
{
sum = sum + next;
count++;
}
average = sum/count;

3
Contributors
3
Replies
4
Views
9 Years
Discussion Span
Last Post by VernonDozier
0

Before doing anything you have to know what the data file looks like. Can you post a few lines from it? Or just attach it to your post.

0

The data file is a set of floating point numbers. Here they are the ones I have in my data file:
1.2
3.3
1.5
2.9
2.5
2.1

0

The data file is a set of floating point numbers. Here they are the ones I have in my data file:
1.2
3.3
1.5
2.9
2.5
2.1

In order to do the standard deviation, you need to store each number for later use in either an array or a vector. You can do sum and average without storing the numbers, but you can't calculate the standard deviation before knowing the average. Thus set up an array or vector and read all of the data in.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.