OCJP

Second Highest Marks

#include<stdio.h>
#include<conio.h>
void main()
{
int n[10];
int i,max,s;
clrscr();
printf("\n enter the mark:");
for(i=0;i<5;i++)
{
printf("\n enetr:");
scanf("\n %d",&n[i]);
}
max=0;
s=0;
for(i=0;i<5;i++)
{
if(n[i]>max)
{
s=max;
max=n[i];
}
else if(n[i]>s && n[i]!=max)
{
s=n[i];
}
}
for(i=0;i<5;i++)
{
printf("\n marks of student %d is %d ",i,n[i]);
}
printf("\n second highest marks is %d",s);

getch();
}

Leave a Reply

Your email address will not be published. Required fields are marked *


× How can I help you?