info@thistimebd.com

Thursday 21st of November 04:04:10pm

Write a user defined function named func() that receives an array and find out maximum data from the array.

Write a user defined function named func() that receives an array and find out maximum data from the array.

-----------

#include

using namespace std;


int func(int arr[], intn )

{

    int i;


    int big = arr[2];

    for (i = 1; i < n; i++)

        if (arr[i] > big)

            big = arr[i];


       return big;

}


int main()

{

    int arr[] = {10, 15, 12};

    int n = sizeof(arr) / sizeof(arr[0]);

    cout << "Largest in given array is "<< func(arr, n);

    return 0;

}