Thursday, July 22, 2010

Program to find maximum element from 1D array ( GTU Sem I Program No : 19)

/*Program to find maximum element from 1D array
  Program No   : 19 of GTU Practice Programs SEM I
  Developed by : Malhar Vora
  Developed on : 20/07/2010
  Email        : vbmade2000@gmail.com
  Web Site     : http://malhar2010.blogspot.com
****************************************************************************/


#include

#define LIMIT 5

int getMax(int *arr,int n)
{
   int i,max;
   max=arr[i];
   for(i=0;i
   {
      if(arr[i]>max)
     max=arr[i];
   }
   return max;
}

void main()
{
   int arr[LIMIT],i,max=0;
   clrscr();

   printf("Enter elements in array :");
   for(i=0;i
   {
      scanf("%d",&arr[i]);
   }


   printf("Max is : %d",getMax(arr,LIMIT));

}

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.