hey everybody. im new here and i just started using c++. i based this code off of the code in the function tutorial. basically, it was meant to ask for how many numbers you would like to multiply, then ask you what the numbers were and multiply them. i thought i would store the information for the multiple numbers in an array. i dont understand the subject all that well so any help would be appreciated. i keep getting incorrect answers when i run the code. here it is.
Code:
#include <iostream>
using namespace std;
int multiply(int array[10], int a, int b, int number);
int main()
{
int c = 1, b = 1, a = 1, number, array[10];
cout << "How many numbers would you like to multiply? ";
cin >> number;
cout << "Please input " << number << " numbers to be multiplied: ";
// store information to array
while (c <= number)
{
cin >> array[b];
c ++;
b ++;
}
cout << "The product of the " << number << " numbers is: " << multiply(array, a, b, number)
<< endl;
return 0;
}
int multiply(int array[10], int a, int b, int number)
{
b = 1;
//retrieve information from array
while (b <= number)
{
a = a + array[b];
b ++;
}
return a;
}
thanks for any help.