#include <iostream>
#include <vector>

int sum(std::vector<int> &arr, int sz){
    if(sz==0){
        return 0;
    }
    
    return arr[sz-1] + sum(arr,sz-1);
}

int main() {
    std::vector<int> arr = {1,2,3,4,5,6,7,8,9};
    int sz = arr.size();
    int sm = sum(arr, sz);
    std::cout<<sm<<std::endl;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: