topical media & game development

talk show tell print

basic-program-code-03-Ex3-08.c

? / basic-program-code-03-Ex3-08.c


  // Ex3_08.cpp
  // Summing integers with a for loop
  include <iostream>
  
  using std::cin;
  using std::cout;
  using std::endl;
  
  int main()
  {
     int i = 0, sum = 0;
     const int max = 10;
  
     for(i = 1; i <= max; i++)       // Loop specification
        sum += i;                    // Loop statement
  
     cout << endl
          << "sum = " << sum
          << endl
          << "i = " << i
          << 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.