C Programs

Write a C program which finds second maximum number?


/* C Program which finds Second Maximum number*/
#include <stdio.h>
#include<conio.h>
int main()
{
       int array[] = {1,2,34,156,436,3};/* give input here*/
       int length = 6; /* give legth here*/
       int firstMax = 0;
       int secondMax= 0;
       int i;
       clrscr();
       for(i = 0; i<length;i++){
     if(firstMax < array[i]){
   secondMax = firstMax;
   firstMax = array[i];
     }
       }
       printf("First Max Number:%d\n",firstMax);
       printf("Second Max Number:%d\n",secondMax);
       getch();
       return 0;
}
www.000webhost.com