1.Finding Quadrant Program

1.Accept Simple Point from the keyboard and check whether it is a origin on x axis , on y axis or in 1st quadrant or in 2nd or in 3rd or in 4th quadrant where exactly the point can be?

Code:

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

namespace quadrant
{
    class Program
    {
        static void Main(string[] args)
        {
            int a,b;
            Console.WriteLine("Please Enter the Point x and y (Ex: 1,2)");
            a=int.Parse(Console.ReadLine());
            b=int.Parse(Console.ReadLine());
            if (a == 0 && b == 0)
            {
                Console.WriteLine("Origin");
            }
            if (a>0 && b>0)
            {
                Console.WriteLine("first quadrant");
            }
            if (a < 0 && b > 0)
            {
                Console.WriteLine("second quadrant");
            }
            if (a < 0 && b < 0)
            {
                Console.WriteLine("third quadrant");
            }
            if (a > 0 && b < 0)
            {
                Console.WriteLine("fourth quadrant");
            }

        }
    }
}
 

2 comments:

  1. this is so easy to learn bt i dont think that it's ll be in interview sessions

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete