next up previous
Next: Problem 3 Up: TwelfthWeek Previous: Problem 1

Problem 2

#include <iostream>
#include <string>
using namespace std;


int counter = 0;

void f() {
   ++counter;
}

void g() {
   f();
   f();
}

void h() {
   f();
   g();
   f();
}

int main() {
   f();

   cout << counter << endl;
   counter = 0;

   g();

   cout << counter << endl;
   counter = 0;

   h();

   cout << counter << endl;
   return 0;
}
What output is produced?



cs101 senior TA 2005-10-24