How to Find The Largest Number of C#

Find The Largest  of Three Number 



In This Example the Largest Number Among Three Number (The user By Entered).
Code:




using System;
namespace Three_Number
{
    class Program
    {
        static void Main(string[] args)
        {
            int num1, num2, num3;
            Console.Write("Find the largest of three numbers:\n");
            Console.Write("\n\n");

            Console.WriteLine("Enter 1st number :");
            num1 = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Enter  2nd number :");
            num2 = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Enter  3rd  number :");
            num3 = Convert.ToInt32(Console.ReadLine());

            if (num1==num2 && num2==num3 && num3==num1)
            {
                {
                    Console.WriteLine("The number are equal");
                }
                if (num1 > num2)
                if (num1 > num3)
                {
                    Console.Write("The 1st Number is the greatest among three. \n\n");
                }
                else
                {
                    Console.Write("The 3rd Number is the greatest among three. \n\n");
                }
             
            }
            else if (num2 > num3)
                Console.Write("The 2nd Number is the greatest among three \n\n");
            else
                 Console.Write("The 3rd Number is the greatest among three \n\n");
 
        }
    }
}



Sharing is Caring 👍👍👍


Thanks For Watching 😉😉

*

Post a Comment (0)
Previous Post Next Post