C Program to find Smallest element from the array
C program in the C programming language to find the smallest element of the array of any size. Below is the code of the C program -
/* C program to find the smallest element or no. form the array */
#include<stdio.h>
#include<conio.h>
void main()
{
int ar[100],n,i,small=0;
printf("Enter the size of the array \n");
scanf("%d",&n);
printf("Enter the elements of the array \n");
for(i=0;i<n;i++)
{
scanf("%d",&ar[i]);
}
small=ar[0];
for(i=0;i<n;i++)
{
if(ar[i]<=small)
{
small=ar[i];
}
}
printf("\n Smallest number of the array is %d",small);
getch();
}
No comments yet