View Single Post
  #1 (permalink)  
Old May 5th, 2007, 08:51 AM
SolarEnergy SolarEnergy is offline
Authorized User
Join Date: Dec 2006
Location: , , .
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapt 5, exercise 10


Just as a curiosity, did anyone understand the exercise 10 in chapter 5?

to make the whole story real short, here's what it is about :
int main (int argc, char* argv[])
  cout << sum(2,4,6,8,10,12) << endl;
  cout << sum(11,22,33,44,55,66,77,66,99) << endl;
** edit**
Strangely, the c++/cli example that uses the sum function works perfectly.

There must be an erratum section on this site, I think I'll try to find it.

Mister Hortons says that this example should produce the following output

My question is : why would sum(2,4,6,8...) only result in 10 ??

I didn't include the function sum in my example, but I would assume a sum function to calculate the sum of all arguments supplied to the function.

Em I missing anything? Most probably ;)

Reply With Quote