void main()
{
int A[25], max, min, maxpos, minpos, n, i;
clrscr();
printf(“nnt ENTER THE SIZE OF THE ARRAY…: “);
scanf(“%d”, &n);
printf(“nnt ENTER THE ELEMENTS OF THE ARRAY…: “);
for(i=1; i<=n; i++)
{
gotoxy(25, 15+i);
scanf(“%d”, &A[i]);
}
max = A[1];
maxpos = 1;
for(i=1; i<=n; i++)
{
if(max<A[i])
{
max = A[i];
maxpos = i;
}
}
min = A[1];
minpos = 1;
for(i=1; i<=n; i++)
{
if(min>A[i])
{
min = A[i];
minpos = i;
}
}
printf(“nnt THE LARGEST ELEMENT IS…: %d”, max);
printf(“nnt AND ITS POSSITION IS…: %d”, maxpos);
printf(“nntTHE SMALlEST ELEMENT IS…: %d”, min);
printf(“nnt AND ITS POSSITION IS…: %d”, minpos);
getch();
}
Not Satisfied ? Just search & get the result
Related posts:
- C program to read in four integer numbers into an array and find the average of largest two of the given numbers without sorting the array. The program should output the given four numbers and the average with suitable headings.
- C Program To find the fibonacci numbers below a given number.
- C Program to find the prime numbers below a given number.
- C Program to find the perfect numbers below a given number.
- C program to accept a list of data items and find the second largest and second smallest elements in it. And also computer the average of both. And search for the average value whether it is present in the array or not. Display appropriate message on successful search.
