topical media & game development

talk show tell print

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

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


  // Ex3_09.cpp
  // Using multiple counters to show powers of 2
  include <iostream>
  include <iomanip>
  
  using std::cin;
  using std::cout;
  using std::endl;
  using std::setw;
  
  int main()
  {
     long i = 0, power = 0;
     const int max = 10;
  
     for(i = 0, power = 1; i <= max; i++, power += power)
        cout << endl
             << setw(10) << i << setw(10) << power;     // Loop statement
  
     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.