C Write Function Find Product First N Numbers Number J Function Receive 3 Integer Paramete Q37121303

C++

write a function that will find the product of the first nnumbers from a number i to j. The function will receive 3 integerparameters (n, i and j) and find the respective product.


Solution


#include <iostream>using namespace std;int product(int n, int i, int j) { int result = 1; for(int num = i, count = 0; num <= j && count < n; num++, count++) { result *= num; } return result;}int main() { cout << product(2, 2,

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.