129. Wap to find largest element from given integer array also find its index.
#include<stdio.h>
int
a[10]={1,3,5,7,3,6,15,5,18,8},ele,i,l,ind;
void
main()
{
ele=sizeof(a)/sizeof(a[0]);
//for(i=0;i<ele;i++)
//
scanf("%d",a+i);
printf("\n");
for(i=0;i<ele;i++)
printf("%d ",*(a+i));
l=a[0];
ind=0;
for(i=1;i<ele;++i)
{
if(a[i]>l)
{
l=a[i];
ind=i;
}
}
printf("\n");
printf("Largest Number :
%d\n",l);
printf("Index : %d\n",ind);
}
Comments
Post a Comment