#include // sumVecRecur // A function to add the first "size" entries // of the vector "data". // double sumVecRecur( double data[], int size ) { if (size == 0) return 0.0; else return (data[ size-1 ] + sumVecRecur( data, size-1 )); } /* The above is recursive, but not tail-recursive. * Exercise: convert it! */ int main() { const int N = 30; double myVec[ N ]; cout << "The sum of entries 0 through " << N-1 << " is " << sumVec( myVec, N ) << ".\n"; }