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; }



LinkBack URL
About LinkBacks


