Sunday, 5 January 2014

TO FIND THE 2ND MAXIMUM NUMBER FROM ARRAY WITHOUT SORTING....!!!!

#include<stdio.h>
int main()
{
    int arr[10],count[10]={0};
    int x,y;
   printf("Enter the elements of array:");
    printf("Enter the elements of array:");
    for(x=0;x<10;x++)
    scanf("%d",&arr[x]);
    int max=0;
    for(y=0;y<10;y++)
    {
       for(x=0;x<10;x++)
       {
       if(arr[y]<arr[x])
       count[y]++;
       }
    }
     for(x=0;x<10;x++)
     {
      if (count[x]==1)
      printf("2nd Maximum number is:%d",arr[x]);
     }
    getch();
    return 0;
}

No comments:

Post a Comment