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 *


Please wait...

Subscribe to our newsletter

Want to be notified when our article is published? Enter your email address and name below to be the first to know.
× How can I help you?
Comodo SSL