- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Array product in C++ using STL
This is an example of C++ program to find out Array Product.
Algorithm
Begin Initialize the values of array. Call used defined function accumulate to return the product of array. Print the solution. End.
Example Code
#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); }
Output
Product of the Array is:42
Advertisements