Using recursion create a program that will allow for a user
Using recursion, create a program that will allow for a user to enter 5 numbers. The program will provide the product of all 5 numbers using recursive methods.
Solution
#include<iostream>
 using namespace std;
void inputData(int numbers[],int index)
 {
 if(index>=5)
 return;
 else
 {
 cout << \"Input number \" << index+1;
 cin >>numbers[index];
 inputData(numbers,index+1);
 }
 }
int product(int numbers[],int index)
 {
 if(index>=5)
 return 1;
 else
 return numbers[index]*product(numbers,index+1);
 }
int main()
 {
 int numbers[5];
 inputData(numbers,0);
 cout << \"Product is : \" << product(numbers,0);
 return 0;
   
 }
OUTPUT:
Input number 1 : 1
Input number 2 : 2
Input number 3 : 3
Input number 4 : 4
Input number 5 : 5
Product is : 120

