Find the greatest of 3 numbers.

Ddd
Posted by Ddd under C# category on | Points: 40 | Views : 2784
//PLEASE INPUT 3 NUMBERS. THEY MUST BE NONEQUAL.



using System;
class abc
{
static void Main()
{
int x,y,z;
Console.WriteLine("enter 1st number");
x=Convert.ToInt32(Console.ReadLine());
Console.WriteLine("enter 2nd number");
y=Convert.ToInt32(Console.ReadLine());
Console.WriteLine("enter 3rd number");
z=Convert.ToInt32(Console.ReadLine());
if (x >y)
{
if (x > z)
{
Console.WriteLine("highest is first and the value is"+"---"+x);
}
else
{
Console.WriteLine("highest is third and the value is"+"----"+z);
}
}
else if (y>z)
{
Console.WriteLine("highest is second and the value is"+"---"+y);
}
else
{
Console.WriteLine("highest is third and the value is"+"---"+z);
}
}
}

Comments or Responses

Login to post response