Display Largest Element of an array Test Case 1 Input (stdin) 5 1 2 3 4 54 Expected Output 54 Test Case 2 Input (stdin) 8 1 2 3 55 123 2 1 99 Expected Output 123
#include <stdio.h>
int main()
{
int a[10],n,j,i,temp;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<n;i++)
{
for (j=0;j<n;j++)
{
if(a[i]<a[j])
{
a[i]=temp;
a[i]=a[j];
temp=a[j];
}
}
}
printf ("%d",a[n-1]);
return 0;
}