EmbLogic's Blog

Largest Element Using Function and Array

#include <stdio.h>
int largest(int []);
int largest(int arr[5])
{
int l,i;
l = arr[0];
for(i=1;i<5;i++)
{
if (arr[i] > l)
{
l = arr[i];
}
else ;

//printf(“%d”,l);
}

return l;
}

int main()
{
int i, max;
int arr[5];
printf(“Enter Elements of array:\n”);
for(i=0;i<5;i++)
{
scanf(“%d”, &arr[i]);
}
for(i=0;i<5;i++)
{
printf(“Array->%d of %d\n:”,i,arr[i]);

}
max = largest(arr);
printf(“largest element is %d\n:”, max);
}

“largest_func.c” 38L, 476C                                                                             33,3-17       44%

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>