Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- int findProductArray(int arr[], int n);
- int findProductArrayRecursive(int arr[], int n, int i);
- using namespace std;
- int main() {
- int arr[] = {1, 3, 4, 5};
- cout << findProductArray(arr, 6);
- return 0;
- }
- int findProductArray(int arr[], int n) {
- return findProductArrayRecursive(arr, n, 0);
- }
- int findProductArrayRecursive(int arr[], int n, int i) {
- if (i == n) {
- return 1;
- } else {
- int currentIndex = i;
- return arr[currentIndex] * findProductArrayRecursive(arr, n, i+1);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement