Correct the following so that it accomplishes what the comment states it is supp
ID: 3553863 • Letter: C
Question
Correct the following so that it accomplishes what the comment states it is supposed to do.
/***********************************
Returns the product of the values entered and how
many values were entered.
User is asked how many values will be entered.
*************************************/
void getProduct()
{
int num, product;
cout << "How many values are to be entered: ";
cin = num;
for ( i = 1. i < num. ++i )
cout << "Enter a value: ";
cin = val;
product *= product * val;
}
Explanation / Answer
void getProduct()
{
int num, product, i, val; // i and val not declared
cout << "How many values are to be entered: ";
cin >> num; // it should be >>, not =
for ( i = 1; i < num; ++i ) // there should be semicolons, not dots.
cout << "Enter a value: ";
cin >> val; // it should be >>, not =
product *= product * val;
}