Pages

Write A Program To Find A Maximum Number In Array

Wednesday, 8 May 2013


#include <stdio.h>
#include <conio.h>
int main()
{
  int array[100], maximum, s, d, l = 1;

  printf("Enter the number of elements in array\n");
  scanf("%d", &s);

  printf("Enter %d integers\n", s);

  for (d = 0; d < s; d++)
    scanf("%d", &array[d]);

  maximum = array[0];

  for (d = 1; d < s; d++)
  {
    if (array[d] > maximum)
    {
       maximum  = array[d];
       l = d+1;
    }
  }

  printf("Maximum element is present at location %d and it's value is %d.\n", l, maximum);
 getch();
}

 

Search Box

Most Reading

Contact Form

Name

Email *

Message *