Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Can I get some help with this computer science assignement? // Write a function

ID: 3760994 • Letter: C

Question

Can I get some help with this computer science assignement?

// Write a function that multiplies each element in the array "myArray"
// by the variable "multiplyMe".

#include <iostream>

using namespace std;

// TODO - Write your function prototype here


int main()
{
    const int SIZE = 10;
    int myArray [SIZE] = {5, 10, 15, 20, 25, 30, 35, 40, 45, 50};
    int multiplyMe = 5;

   // TODO - Add your function call here


   // print the array
    for(int i=0; i < SIZE; i++)
    {
        cout << myArray[i] << " ";
    }
    cout << endl;

    return 0;

}

// TODO - Write your function definition here

Explanation / Answer

#include <iostream>

using namespace std;

// TODO - Write your function prototype here
void multiplyArray(int *arr,int multiplyMe,int size);

int main()
{
    const int SIZE = 10;
    int myArray [SIZE] = {5, 10, 15, 20, 25, 30, 35, 40, 45, 50};
    int multiplyMe = 5;

    // TODO - Add your function call here

   multiplyArray(myArray,multiplyMe,SIZE);
    // print the array
    for(int i=0; i < SIZE; i++)
    {
        cout << myArray[i] << " ";
    }
    cout << endl;

    return 0;

}

// TODO - Write your function definition here
void multiplyArray(int *arr,int multiplyMe,int size)
{
   for(int i=0; i < size; i++)
       arr[i] = arr[i]*multiplyMe;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote