ads

Sunday, 28 August 2016

c program to find minimum element from array

#include <stdio.h>
#include <conio.h> 
void main()
{
  int a[100],min,n,i,location = 1;
  printf("Enter the number of elements in array\n");
  scanf("%d", &n);
  printf("Enter the numbers\n"); 
  for (i = 0; i < n; i++)
  scanf("%d", &a[i]);
  min = a[0];
  for (i = 1; i < n; i++)
  {
    if (a[i] > min)
    {
       max  = [i];
       location = i+1;
    }
  }
  printf("Minimum element is present at location %d and it's value is %d.\n", location,               
  max);
  getch();
}

No comments:

Post a Comment