Problem Description
Three numbers A, B and C are the inputs. Write a program to find second largest among three numbers. The first line contains an integer T, total number of testcases. Then follow T lines, each line contains three integers A, B and C. Display the second largest among A, B and C.CODING ARENA::
#include <stdio.h>
int main()
{
int a,b,c;
scanf("%d\t%d\t%d",&a,&b,&c);
if(a>b && a>c)
{
if(b>c)
{
printf("%d",b);
}
else
{
printf("%d",c);
}
}
else if(b>a && b>c)
{
if(a>c)
{
printf("%d",a);
}
else
{
printf("%d",c);
}
}
else if(c>a && c>b)
{
if(a>b)
{
printf("%d",a);
}
else
{
printf("%d",b);
}
}
return 0;
}
Test Case 1
Input (stdin)100 23 299
Expected Output100
Test Case 2
Input (stdin)30 122 14
Expected Output30
No comments:
Post a Comment