Website Summary Files Commits Branches @commit @diff @stats
path: root / Sem. 13 / task5.cpp
blob: 5e38f281430cd383e8da7b43dfde55d626c00238 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <iostream>
using namespace std;

int sum(const int* arr, int len)
{
	if (len == 0)
		return 0;

	return arr[0] + sum(arr+1, len - 1);
}

int main()
{
	int arr[] = { 1, 2, 2, 6 };
	cout << sum(arr,4);
}