#include<stdio.h>
int small(int a[],int n)
{
int
s,i; s=a[0];
for(i=0;i<n;i++)
{
if(a[i]<s)
s=a[i];
}
return s;
}
main()
{
int i,a[10],n,s;
printf("Enter
total no. of elements\n"); scanf("%d",&n);
printf("Enter
Array Elements one by one\n"); for(i=0;i<n;i++)
scanf("%d",&a[i]); printf("Array
Elemets:\n"); for(i=0;i<n;i++)
printf("%d\t",a[i]);
printf("\n");
s=small(a,n);
printf("The Smallest element of given array is
%d",s); }
OUTPUT:
Enter
total no. of elements 5
Enter Array
Elements one by one 1 98 2 66 0
Array Elemets:
1 98 2 66 0
The Smallest element of
given array is 0
No comments:
Post a Comment