Hi, I am vvv new to C++ and doing a course on it. The first assignment i have is to reading in and print out numbers from a file, then calculate the avearage of the numbers, the sum and the standard deviation.
Ive written two separate codes so far, one to print out the numbers and another to calc the sum and the average (not tackled sd yet). But when i put them together, the program only prints out the numbers and im not sure where im going wrong:
[code]
include <iostream>
#include <stdio.h>
#include <cmath>
#include <string>
#include <sstream>
#include <fstream>
using namespace std;
int main()
{
int n;
int Points[99] = {0};
cout << "Enter a file name" << endl;
string name;
cin >> name;
ifstream input(name);
if(input.is_open())
{
while(! input.eof())
{
getline (input,name);
stringstream convert(name);
fstream input(name);
if (input)
{
double total = 0;
double count = 0;
double n;
while (input >> n) {
total = total + n;
count++;
}
double average = total / count;
cout << " the sum is " << total << endl;
cout << " the average is " << average << endl;
}
}
else
cout<<"file is not open"<< '\n';