making this array

i have to write a function called scaleData that accepts an array of doubles and a double named scaleFactor. The function must multiple each element of data by the scaleFactor which must be non-zero. if the scale factor in non-zero, return 0; otherwise return 1 (an error code of sorts)

double scaleData( int scaleFactor, int arraySize)
{
double sum = 0;
for (int i = 0; i < arraySize; i++)
sum = sum*scaleFactor;

return 0;
}
this is what i have help me correct this please
You'll need to pass in the array, at least.
Well you have to pass the array as a parameter, an example of which is illustrated here: http://www.cplusplus.com/doc/tutorial/arrays/. You're right in using the for loop, but you need to multiply each element, not just one value. Here's some pseudocode:

1
2
3
4
5
6
7
8
9
10
11
12
13
double scaleData (int scaleFactor, int arg[], int length)
{
    // if scale factor is zero return 1
    if (scaleFactor == 0)
        return 1;

    for (int n=0; n<length; ++n)
    {
        // multiply every element by scaleFactor
    }

    return 0;
}
what is suppose to go in the multiple every element part of this array?
Topic archived. No new replies allowed.