#include <stdio.h>
#include <conio.h>
void main()
{
int a[100],max,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]);
max = a[0];
for (i = 1; i < n; i++)
{
if (a[i] > max)
{
max = a[i];
location = i+1;
}
}
printf("Maximum element is present at location %d and it's value is %d.\n", location,
max);
getch(); }
No comments:
Post a Comment