Monday, 9 July 2012

Compare five numbers

Compare five number which is greater ?


using System;
class Five
{
public static void Main()
{
int a, b,c,d,e;
Console.WriteLine("enter 1st no .");
a=Convert.ToInt32(Console.ReadLine());
Console.WriteLine("enter 2nd no .");
b=Convert.ToInt32(Console.ReadLine());
Console.WriteLine("enter 3rd no .");
c=Convert.ToInt32(Console.ReadLine());
Console.WriteLine("enter 4th no .");
d=Convert.ToInt32(Console.ReadLine());
Console.WriteLine("enter 5th no .");
e=Convert.ToInt32(Console.ReadLine());
if((a==b)||(a==c)||(a==d)||(a==e)||(b==c)||(b==d)||(b==e)||(c==d)||(c==e)||(d==e))
{
Console.WriteLine("ur some no are same enter differ no for comparison");
}
else if((a>b)&&(a>c)&&(a>d)&&(a>e))
{
Console.WriteLine("1st is greater than all no.");
}
else if((b>a)&&(b>c)&&(b>d)&&(b>e))
{
Console.WriteLine("2nd is greater than all no.");
}
else if((c>a)&&(c>b)&&(c>d)&&(c>e))
{
Console.WriteLine("3rd is greater than all no.");
}
else if((d>a)&&(d>b)&&(d>c)&&(d>e))
{
Console.WriteLine("4th is greater than all no.");
}
else
{
Console.WriteLine("5th is greater");
}
}
}

No comments:

Post a Comment