How to find second highest number in array by c programming
How to find second highest number in array by c programming
if you are using turbo c compiler please use #include<conio.h> header file. and if you are using devc++ or any other compiler than simply go through the given program below.
#include <stdio.h>
int main(){
char a[20],i,n,temp;
printf("enter size of array\n");
scanf("%d",&n);
printf("enter elements of array\n");
for(i=0;i<n;i++){
scanf("%d",&a[i]);
}
for(i=0;i<n;i++){
if(a[i]>a[0])
{
temp=a[0];
a[0]=a[i];
a[i]=temp;
}
}
for(i=1;i<n;i++){
if(a[i]>a[1]){
a[1]=a[i];
}
}
printf("second highest number is %d\n",a[1]);
}
Again Thanks Great Code !!
ReplyDelete