GlobalSumCounter

GlobalSumCounter - cout<<"Adding 5 and 6...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
#include <iostream> using namespace std ; int counter = 0 ; int sum(int a, int b) { ++ counter ; return a + b ; } int main() { cout << "Let's add some numbers. .." << endl ; cout << "Adding 1 and 2 yeilds " << sum(1,2) << "." << endl ; cout << "Adding 3 and 4 yeilds " << sum(3,4) << "." << endl ;
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: cout << "Adding 5 and 6 yeilds " << sum(5,6) << "." << endl ; cout << "Adding 7 and 8 yeilds " << sum(7,8) << "." << endl ; cout << "Adding 9 and 10 yeilds " << sum(9,10) << "." << endl ; cout << endl ; cout << "We've called sum " << counter << " times." << endl ; }...
View Full Document

This note was uploaded on 10/28/2010 for the course CSCI 1113 taught by Professor Staff during the Spring '08 term at Minnesota.

Ask a homework question - tutors are online