C# program for Comparison Operator








using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;



namespace ConsoleApplication100

{

    class Program

    {

        static void Main(string[] args)

        {

            int a, b;     // variable declaration



            //want two inputs from the user

            Console.Write("Enter number value of a\t");   // here user insert value of a

            a = Convert.ToInt32(Console.ReadLine());

            Console.Write("Enter number value of b\t");  // here user insert value of b

            b = Convert.ToInt32(Console.ReadLine());



            //comparison will process

            //now, Check whether a is greater than b or not

            if (a > b)

            {

                Console.WriteLine("{0} is greater than {1}", a, b);

            }

            //then, Check whether b is greater than a or not

            else if (b > a)

            {

                Console.WriteLine("{0} is greater than {1}", b, a);

            }

            else

            {

                Console.WriteLine("{0} and {1} are equal", a, b);

            }

            Console.ReadLine();

        }

    }

}



Output : 


Previous Post Next Post