i need to find the sum of rounded to one number after the dot numbers(don't know the right way to call it)(1.63 = 1.6; 3.525=3.5 etc) in a txt file located in the same folder as my project. the numbers are wtitten through enter (new line = new number). i've got something, but it doesn't work properly. could you please check and help me finish the code.
#include<fstream>
#include<iostream>
#include<cmath>
usingnamespace std;
int main()
{
double a, sum = 0.;
ifstream in("laura.txt");
if (in.is_open())
{
while (in >> a)
{
sum += round(a * 10.) / 10.;
}
in.close();
}
else cout << "Unable to open file\n";
cout << "sum=" << sum << "\n";
system("pause");
return 0;