Write a C language program to find the smallest element from an array.
#include<stdio.h>
#include<conio.h>
void main()
{
int small, arr[100], size, i;
printf("Enter Array Size: ");
scanf("%d",&size);
printf("Enter %d elements in an array : ",size);
for(i=0; i<size; i++)
{
scanf("%d",&arr[i]);
}
small=arr[0];
for(i=0; i<size; i++)
{
if(small>arr[i])
{
small=arr[i];
}
}
printf("Smallest Element = %d",small);
getch();
}
Input/Output:
Enter Array Size: 5
Enter 5 elements in an array: 5 3 1 4 2
Smallest Element is= 1
No comments
Dear Members, Thanks for Your Comments. We must be reply your comment answer as soon as possible. Please Stay with us.....