include iostream using namespace std template size_t double product au

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
#include <iostream>
using namespace std;
template<size_t S> double product(auto (&array)[S]) {
double value = 1;
for (auto &element: array) {
value *= element;
}
return value;
}
int main() {
float array[5] = {1, 2, 3, 5, 7};
cout << product(array);
}