C Program To find the biggest and smallest number and positions in the given array

by Nideesh C on April 18, 2011 · 0 comments

in C Programming




#include<stdio.h>
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 Plugin for WordPress, Blogger...
Be Sociable, Share!

Related posts:

  1. 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.
  2. C Program To find the fibonacci numbers below a given number.
  3. C Program to find the prime numbers below a given number.
  4. C Program to find the perfect numbers below a given number.
  5. 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.

Leave a Comment

Previous post:

Next post: