1. ## simple program help

SUP!, well i need help, im using visual C++, and i need to write a simple program that reads 100 numbers from 1 to 100 on a txt file, calculates their average, and the standard deviation and then inputs the standard deviation and average into the original file at the bottom:? .....k i know you start off with the basic library's you'll be using and the basic setup and such,, but from there on i am completely lost8O ,........be great if someone could help me writing this out so i can understand what i should be doing..shouldn't take long since i was peeping the forum and people seem C++ savy here...

btw the file im using is called data.txt...and is in the "Temp" folder of my c drive...THIS is attempt so far ....keep in mind im mad beginner ...in essence i need help in the whole std deviation part.

THANKS!

btw this is my code so far, be great if someone could tell me if im ok so far, aslo how i could do the standard deviation, i cant find a way to do it..
Code:
```#include <iostream>
#include <cmath>
#include <fstream>
#include <iomanip>

using namespace std;

int main()
{
float sum = 0, StdDev = 0;
int x = 0;
ifstream inFile;
inFile.open("data.txt");

while ( inFile >> x )
{
sum += x;
}
inFile.close();

ofstream outFile( "data.txt", ios::app );
outFile.seekp( ios::end );
outFile << sum << endl;
outFile.close();
return 0;
}``` 2. 1. Rule 5
2. Do you know what "standard deviation" means in mathematical terms?

I would leave off the "append result to file" part until everything works, otherwise you will end up processing whatever junk you wrote to the file the next time you run the code. 3. Hi, standard deviation just means, how you would normal do something, like 4/2, 4+5, 5*3 so on. I am working out a little example but lol I kinda forgot how to read numbers from a text file XD (guess cus its like 2:38 AM here) Anyways, if you do know how to code it I would just

1. Add all the numbers up, at the same time, getting how many lines it takes to do this. Like...

(This shows how many lines the're, not how to add the numbers in the text file.)
Code:
```#include <iostream>
#include <fstream>
#include <string>

using namespace std;

int main()
{
string line;
int x;
x=0;

ifstream myfile ("tst.txt");
if (myfile.is_open())
{
while (! myfile.eof() )
{
getline (myfile,line);
x=x+1;
cout << line << endl;
}
myfile.close();
}
else cout << "Unable to open file";
cout<<"Sum is "<<x<<endl;
getchar();
}```
After you get all the lines you could just divide the numbers (numbers in the texts / by the number of lines the're) to get the average. Like lets say the number in the text was a sum of 10 and there was 5 lines, so it be 10/5 or 1/2. Popular pages Recent additions 