topical media & game development

talk show tell print

basic-program-solutions-03-Soln3-1A.c

? / basic-program-solutions-03-Soln3-1A.c


  // Soln3_1A.cpp
  include <iostream>
  using std::cin;
  using std::cout;
  using std::endl;
  
  int main()
  {
     int val, total=0;
     cout << "Enter numbers, one per line. Enter 0 to end:\n";
     cin >> val;
  
     while (val != 0)
     {
        total += val;
        cin >> val;
     }
  
     cout << "\nThank you. The total was " << total;
     cout << endl;
     return 0;
  }
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.