EmbLogic's Blog

Finding the largest number in an array

#include<stdio.h>
int main()
{
int a[100],n,i,j;
printf(“enter the value of array:”);
scanf(“%d”,&n);
printf(“enter the value :\n”);
for(i=0;i<n;i++)
{
scanf(“%d”,&a[i]);
}
j=a[0];
for(i=1;i<n;i++)
{
if(j<a[i])
j=a[i];
else
j=j;
}

printf(“Largest element of array is :%d\n”,j);

}

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>