यह ऐरे गुणनफल ज्ञात करने के लिए C++ प्रोग्राम का एक उदाहरण है।
एल्गोरिदम
Begin
ऐरे के मान इनिशियलाइज़ करें।
ऐरे का गुणनफल लौटाने के लिए उपयोगकर्ता परिभाषित फंक्शन accumulate को कॉल करें।
समाधान प्रिंट करें।
End.
उदाहरण कोड
#include <iostream>
#include <numeric>
using namespace std;
int ProductOfArray(int p[], int n) {
return accumulate(p, p + n, 1, multiplies<int>());
}
int main() {
int m[] = {6, 7};
int n = sizeof(m) / sizeof(m[0]);
cout << "Product of the Array is: " << ProductOfArray(m, n);
return 0;
}
आउटपुट
Product of the Array is: 42