123456789101112131415161718192021
#include <iostream> #include <fstream> #include <string> using namespace std; int main() { string data1; ifstream myfile ("file1.txt"); getline (myfile, data1); cout << data1 << endl; myfile.close(); return 0; }
123456789
double total = 0; double n; ifstream myfile ("file1.txt"); while (myfile >> n) total += n; cout << total;