Saturday, March 1, 2014

Boolean02: (Wk-2), Jan 16, 2014

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Boolean002
{
    class Program
    {
        static void Main(string[] args)
        {
            //Q: Request two integers x and y from the user
            //   Then compare them using the six relational
            //   operators and display the results


            int x, y;
            Console.Write("Enter the value of x: ");
            x = Convert.ToInt32(Console.ReadLine());
            Console.Write("Enter the value of y: ");
            y = Convert.ToInt32(Console.ReadLine());

            bool b1, b2, b3, b4, b5, b6;
            b1 = (x > y);
            b2 = (x < y);
            b3 = (x == y);
            b4 = (x != y);
            b5 = (x >= y);
            b6 = (x <= y);

            Console.WriteLine("x= {0}   y = {1}", x, y);
            Console.WriteLine();//skip a line

            Console.WriteLine("is x > y?: " + b1);
            Console.WriteLine("is x < y?: " + b2);
            Console.WriteLine("is x == y?: " + b3);
            Console.WriteLine("is x != y?: " + b4);
            Console.WriteLine("is x >= y?: " + b5);
            Console.WriteLine("is x <= y?: " + b6);

            Console.ReadLine();
        }
    }
}

No comments:

Post a Comment