Thursday, 15 October 2015

Maximum Number between two numbers using ternary operator in C#

using System;
class Program
{
    public static void Main()
    {
        Console.WriteLine("Enter first Number");
        int FirstNumber = int.Parse(Console.ReadLine());
        Console.WriteLine("Enter second Number");
        int SecondNumber = int.Parse(Console.ReadLine());

        int maxNumber = FirstNumber > SecondNumber ? FirstNumber : SecondNumber;
        Console.WriteLine("Maximum Number between {0} and {1} is {2}",FirstNumber,SecondNumber,maxNumber);
    }
}

No comments:

Post a Comment