Maximum no. from array elements using function

Program:

#include<stdio.h>
int max(int m[],int n);
int main()
{
int a[10],n,i;
printf("Enter No. of elements: ");
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
    printf("Maximum: %d",max(a,n));
    return 0;
}
int max(int m[],int n)
{
  int max=0,i;
  for(i=0;i<n;i++)
  {
  if(m[i]>max)
  {
         max=m[i];
}
  }
  return max;
}

Output:



No comments:

Post a Comment

x^y using recursion

Program: #include<stdio.h> int power(int a,int b); int main() { int x,y,ans; printf("Enter x and y:\n "); scanf(...