Hmmmm, I wonder why isn't this working...It gives an error stating "Use of unassigned local variable max". So, what is wrong with this code? I cant figure it out.
namespace ConsoleApplication1
{
class Program
{
public int CalculateHighestNum(int value1, int value2, int value3)
{
int max;
if (value1 > (value2 & value3))
{
max = value1;
}
else if(value2 > (value1 & value3))
{
max = value2;
}
else if(value3 > (value1 & value2))
{
max = value3;
}
return max;
}
static void Main(string[] args)
{
Console.Write("Enter first NUM : ");
int a = Convert.ToInt32(Console.ReadLine());
Console.Write("Enter second NUM : ");
int b = Convert.ToInt32(Console.ReadLine());
Console.Write("Enter third NUM : ");
int c = Convert.ToInt32(Console.ReadLine());
Program p = new Program();
int highestnum = p.CalculateHighestNum(a, b, c);
Console.WriteLine(highestnum + " = Highest Number");
}
}