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

#include <iostream> #include <iomanip> using namespace std; int ArrayI(int Array

ID: 3626659 • Letter: #

Question



#include <iostream>
#include <iomanip>

using namespace std;

int ArrayI(int ArrayM[], int size);

const int size=8;

int main()


{


int max;
int ArrayM[size];




max = ArrayI(ArrayM, size);

cout << " the maximum value is :" << max << endl;

return 0;
}

int ArrayI(int ArrayM[], int size)

{
int max =0;
int largest;
int i;

for (i=0; i< size; i++)
cin >> ArrayM[i];



for (i=1; i<= size; i++)
{
if (ArrayM[max]<ArrayM[i])
{
max=i;
largest = ArrayM[max];
}
}

return max;
}

Explanation / Answer

#include <iostream>
#include <iomanip>
using namespace std;
int ArrayI(int ArrayM[], int size);
const int size=8;
int main()
{
int max;
int ArrayM[size];
max = ArrayI(ArrayM, size);
cout << " the maximum value is :" << max << endl;
return 0;
}
int ArrayI(int ArrayM[], int size)
{
int max =0;
int i;
for (i=0; i< size; i++)
cin >> ArrayM[i];
int largest = ArrayM[0];
for (i=1; i<= size; i++)
{
if (largest<ArrayM[i])
{
max=i;
largest = ArrayM[i];
}
}
return largest;
}