#include<stdio.h>
#include<conio.h>
/*take input from user again and again till user enter a negitive number after this print the second maximum number*/
void main()
{
int max=0, min=0, num=0;
clrscr();
while (num>=0)
{
printf("enter the value of number");
scanf("%d",&num);
if(num>0)
{
if(num>max)
{
min=max;
max=num;
}
else if(num>min)
{
min=num;
}
}
else if (num<0)
{
break;
}
}
printf("second maximum number%d",min);
getch();
}
No comments:
Post a Comment