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;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.