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();
}

yashan has written 70 articles

5 thoughts on “C Program to find Smallest element from the array

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=""> <s> <strike> <strong>