Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- template <size_t sz>
- int sum (const int(&a)[sz]){
- int result = 0;
- for (size_t i = 0; i < sz; ++i){
- result += a[i];
- }
- return result;
- }
- int main()
- {
- int arr [5] = {1,2,3,4,5};
- int sum_result = sum(arr);
- cout << "the sum is = " << sum_result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement