Removing uneeded file.
[and.git] / PC^2 / pc2team / samps / sumit.cpp
blobce9a6b397d3c50a21e6ae77d53e38591d5f53c98
2 //
3 // File: sum1.cpp
4 // Purpose: to sum the integers in the file sumit.dat
5 // Author: pc2@ecs.csus.edu or http://www.ecs.csus.edu/pc2
6 //
7 // Sat Oct 30 12:43:18 PDT 1999
8 //
9 // caveat - this is not nice code, copy at own risk ;)
11 // $Id: sumit.cpp,v 1.1 2005/03/06 05:13:57 laned Exp $
15 #include <iostream.h>
16 #include <fstream.h>
18 main ()
20 int num;
21 int sum;
22 ifstream filein("sumit.dat");
24 if (filein.fail())
26 cerr << "Could not read from file sumit.dat " << endl;
28 else
31 sum = 0;
33 while(!filein.eof())
35 filein >> num;
37 if (num > 0)
39 sum += num;
43 cout << "The sum of the positive integers is " << sum << endl;
48 // eof