//CODE
#include<stdio.h>
int main()
{
int a[10],i,n,large;
printf("\n Enter the size of the array: ");
scanf("%d",&n);
printf("\n Enter the elements of the array: \n");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
large=a[0];
i=1;
while(i<n)
{
if(large<a[i])
{
large=a[i];
i++;
}
else
{
i++;
}
}
printf("\n The largest element in the array is %d \n",large);
return 0;
}
//OUTPUT
Enter the size of the array:6
Enter the elements of the array:
5
8
9
4
1
7
The largest element in the array is 9
#include<stdio.h>
int main()
{
int a[10],i,n,large;
printf("\n Enter the size of the array: ");
scanf("%d",&n);
printf("\n Enter the elements of the array: \n");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
large=a[0];
i=1;
while(i<n)
{
if(large<a[i])
{
large=a[i];
i++;
}
else
{
i++;
}
}
printf("\n The largest element in the array is %d \n",large);
return 0;
}
//OUTPUT
Enter the size of the array:6
Enter the elements of the array:
5
8
9
4
1
7
The largest element in the array is 9
No comments:
Post a Comment
Note: only a member of this blog may post a comment.