Code: #include <iostream> #include <fstream> using namespace std; int main () { ifstream in_file; in_file.open("Summation.dat",ios::in); int i; int A[20]; float sumPos; float sumNeg; in_file >> i; while (!in_file.eof()) { for (i = 0; i < 20; i++) { if (i < 0) sumNeg += A[i]; else sumPos += A[i]; } in_file >> i; } cout << "Sum of Positive Integers = " << sumPos << endl; cout << "Sum of Negative integers = " << sumNeg << endl; in_file.close(); return 0; }
Furthermore, you have nothing in A[] to work with. You will tend to get better responses if you explain how your code is failing to meet your expectations. You're making us guess, is that nice? Fortunately you have some obvious blunders.