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