First page Back Continue Last page Graphics

INVARIENT EXAMPLE

  • // invarient: we have written r rows so far
  • int r = 0;
  • // setting r to 0 makes the invarient true
  • while (r != rows) {
  • // we can asume that the invarient is true here
  • // writing a row of output makes the invarient false
  • cout << endl;
  • // incrementing r makes the invarient true again
  • ++ r;
  • }
  • // we can conclude that the invarient is true here