Input five numbers in an array and find the second highest value.
#include <stdio.h>
#include <conio.h>
#include <math.h>
void main ( )
{
int n[5], i, h = 0, h1 = 0;
clrscr ( );
for ( i = 0; i < 5; i++ )
{
printf ("\n\t\t Enter a number in an array......:"); scanf ("%d", & n[i]);
if ( n[i] > h )
h = n[i];
}
for ( i = 0; i < 5; i++ )
{
if ( n[i] > h1 && n[i] < h )
h1 = n[i];
}
printf ("\n\n\n\t\t The highest number is = %d", h);
printf ("\n\n\n\t\t The second highest number is = %d", h1);
getch ( );
}
Click here to contact us
No comments:
Post a Comment