Find smallest value of an array – C program

smallest value of an array – C Program

Write a c program of fins the smallest values from given array

Here, we will learn how to find the minimum element from an array in c language program.

An Array is a collection of same data type elements.

For find smallest element in array, in below c program first we need to enter five elements in array and using for loop we find the minimum element from existing elements.

#include<stdio.h>

int main()
{
 int a[5],i,min=0;
 printf("Please enter 5 numbers :\n");
 for(i=0;i<5;i++)
  scanf("%d",&a[i]);
 
 min=a[0];
 for(i=1;i<5;i++)
 {
  if(min>a[i])
   min=a[i];
 }
 
 printf("The minimum value of Array =  %d",min);
 return 0;
}

The output of smallest value c program is :

Please enter 5 numbers : 
5 16 18 2 3

The minimum value of Array = 2

 

Author: Meera Academy

Leave a Reply

Your email address will not be published. Required fields are marked *