Skip to content

Commit

Permalink
Update ex1_16.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Mooophy committed Oct 20, 2015
1 parent 526f335 commit 6b81c33
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions ch01/ex1_16.cpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
#include <iostream>

using std::cin;
using std::cout;
using std::endl;
int main()
{
int limit = 0, sum = 0, value = 0;
std::cout << "How many integers would you like to enter?";
std::cin >> limit;

// assume we don't know what is EOF(End-Of-File).
while (std::cin >> value && (--limit != 0))
sum += value;

std::cout << sum + value << std::endl;

int sum = 0;
for (int i = 0; cin >> i; sum += i);
cout << "Sum is: " << sum << endl;
return 0;
}

0 comments on commit 6b81c33

Please sign in to comment.