// Write a function that multiplies each element in the array \"myArray\" // by
ID: 3940858 • Letter: #
Question
// 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
Solution:
#include <iostream>
#include<fstream>
#include<string>
using namespace std;
//TODO: declaration (prototype) for void function GetLeast that takes an ifstream parameter called infile as an input parameter that is changed, and that has an int parameter called arraysize that returns a value.
int main()
{
const int SIZE = 10;
int myArray [SIZE] = {5, 10, 15, 20, 25, 30, 35, 40, 45, 50};
int multiplyMe = 5;
//TODO: Call function GetLeast, passing the multiplyME variable and int variable as arguments.
for(int i=0; i < SIZE; i++)
{
cout << myArray[i] << " ";
}
cout << endl;
return 0;
}
OUTPUT:5 10 15 20 25 30 35 40 45 50
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.