Sunday, September 18, 2011

Finding maximum value of an array in C++

In the following program you can find maximum value of an array:



#include <iostream>


using namespace std;
int min(int*, int);
int main()
{
    int array[]={66,44,88,11,77,33,99,55,22};
    cout<< "min(array,9)=" << min(array,9);
}
int min(int* array, int n)
{


    int m=array[0];
    for(int i=1;i<n;i++)
    if (array[i]>m) m=array[i];
    return m;
}

0 comments em “Finding maximum value of an array in C++”

Post a Comment

Give your valuable Comment...

 

Programming, Data Structures & Algorithms Copyright © 2011 -- Template created by JAK -- Powered by Blogger