What is the c plus plus program that finds max value in the array of size n?

1 answer

Answer

1030310

2026-07-27 16:00

+ Follow

#include <iOStream>

using std::cout;

using std::endl;

double maxValue(double arr, const intarrSize);

int main()

{

const int arrSize = 10;//Size of the array you are going to use

double arr[arrSize] = {0.0};

cout << endl << "Enter the array elements..."

for ( int i = 0; i < arrSize; i++ )

{

cout << endl << "Enter " << (i + 1) << " element:";

cin >> arr[i];

}

cout << endl << "Max value is: " << maxValue;

system("PAUSE");

return 0;

}

double maxValue(double arr, const intarrSize)

{

double max = arr[0];

for ( int j = 0; j < arrSize; j++ )

{

if ( max < arr[j])

{

max = arr[j];

}

}

return max;

}

ReportLike(0ShareFavorite

Copyright © 2026 eLLeNow.com All Rights Reserved.