Minimum Element in an Array in C programming

Image result for c programming

Minimum Element in an Array in C programming
Code:
  #include<stdio.h>
int main(){
  int n, a[20], i,min=1;
  scanf("%d",&n);
  for(i=0;i<n;i++)
  {
    scanf("%d",&a[i]);
  }
  min=a[0];
  for(i=1;i<n;i++)
  {
    if(a[i]<min)
      min=a[i];
  }
  printf("%d is the minimum element in the array",min);
  return 0;
}

No comments