Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int total (int arr_len, int *arr)
- {
- if ( arr_len == 0 )
- return 0;
- return *arr + total(--arr_len, arr + 1);
- }
- int main ()
- {
- int arr[] = {1,2,3,4,5,6,7,8,9};
- int arr_len = sizeof(arr) / sizeof(arr[0]);
- cout << total(arr_len, arr) << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement