Click here to Skip to main content
15,893,588 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
class compare
{
    int num1, num2, num3;

    public void accept()
    {
        Console.WriteLine("Enter First Number");
        num1 = Convert.ToInt32(Console.ReadLine());
        Console.WriteLine("Enter Second Number");
        num2 = Convert.ToInt32(Console.ReadLine());
        Console.WriteLine("Enter Third Number");
        num3 = Convert.ToInt32(Console.ReadLine());
    }
    public void display
    {
    if(num1>num2)&&(num1>num3)
    {
        Console.WriteLine("This No is greatest {0}",num1);
    }
        else if(num2>num1)&&(num2>num3)
    {
        Console.WriteLine("This No is greatest {0}",num2);
    }
        else{
        Console.WriteLine("This No is greatest {0}",num3);
    }
    }
     static void Main(string[] args)
        {
            compare  cmp = new compare();
            cmp.accept();
            cmp.display();
        }
}
Posted
Updated 20-Jun-10 8:05am
v2

1 solution

Compare your code with this. You have not added the () properly in your if else block.

Following code is working fine.

class compare
{
    int num1, num2, num3;

    public void accept()
    {
        Console.WriteLine("Enter First Number");
        num1 = Convert.ToInt32(Console.ReadLine());
        Console.WriteLine("Enter Second Number");
        num2 = Convert.ToInt32(Console.ReadLine());
        Console.WriteLine("Enter Third Number");
        num3 = Convert.ToInt32(Console.ReadLine());
    }
    public void display()
    {
            if((num1>num2)&&(num1>num3))
            {
                Console.WriteLine("This No is greatest {0}",num1);
            }
             else if((num2>num1)&&(num2>num3))
            {
                Console.WriteLine("This No is greatest {0}",num2);
            }
                else
            {
                Console.WriteLine("This No is greatest {0}",num3);
            }
            
    }
    static void Main(string[] args)
    {
        compare cmp = new compare();
        cmp.accept();
        cmp.display();
        Console.Read();
    }

}
 
Share this answer
 
v2
Comments
jain1987 21-Jun-10 14:17pm    
Thank U ....
PSK_ 21-Jun-10 21:51pm    
If your issue is resolved then close the question.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900