Program to find largest element and its position in an array using pointer.



To find largest element and is position in an array using pointer.

#include
#include

main()
{
int a[20],i,n,l,p=0;
int *b;
clrscr();
printf("\nInput array size ");
scanf("%d",&n);
printf("\Input %d array elements\n",n);
for(i=0;iscanf("%d",&a[i]);
b=a;
l=0;
printf("\nEntered array is \n");
for(i=0;i{
printf("\n%d",*b);
if(*b>1)
{
l=*b;
p=i+1;
}
}
printf("\nLargest element is %d at position %d",l,p);
}

No comments:

Post a Comment