mercredi 4 mars 2015

c program to print second largest number of three number given as input by using if else loop without bitwise operator

// Print second largest number of three number given as input



#include <stdio.h>

int main()

{
int a,b,c,lar,seclar;

scanf("%d%d%d",&a,&b,&c);

if(a>b)
{
if(a>c)
lar=a;
else
seclar=a;
}

if(b>c)
{
if(b>a)
lar=a;
else
seclar=b;
}
if(c>a)
{
if(c>b)
lar=c;
else
seclar=c;
}
printf("second largest number :%d",seclar);


}


........in this program if i input the numbers in sequence the result is correct but otherwise the result always comes "2" can anyone help me in this>>>Thanks


Aucun commentaire:

Enregistrer un commentaire