C# Sharp exercises: Find the quadrant in which the coordinate point lies
C# Sharp Conditional Statement : Exercise-9 with Solution
Write a C program to accept a coordinate point in an XY coordinate system and determine in which quadrant the coordinate point lies.
Sample Solution:-
C# Sharp Code:
using System;
public class Exercise9
{
public static void Main()
{
int co1,co2;
Console.Write("\n\n");
Console.Write("Find the quadrant in which the coordinate point lies:\n");
Console.Write("------------------------------------------------------");
Console.Write("\n\n");
Console.Write("Input the value for X coordinate :");
co1 = Convert.ToInt32(Console.ReadLine());
Console.Write("Input the value for Y coordinate :");
co2 = Convert.ToInt32(Console.ReadLine());
if( co1 > 0 && co2 > 0)
Console.Write("The coordinate point ({0} {1}) lies in the First quandrant.\n\n",co1,co2);
else if( co1 < 0 && co2 > 0)
Console.Write("The coordinate point ({0} {1}) lies in the Second quandrant.\n\n",co1,co2);
else if( co1 < 0 && co2 < 0)
Console.Write("The coordinate point ({0} {1}) lies in the Third quandrant.\n\n",co1,co2);
else if( co1 > 0 && co2 < 0)
Console.Write("The coordinate point ({0} {1}) lies in the Fourth quandrant.\n\n",co1,co2);
else if( co1 == 0 && co2 == 0)
Console.Write("The coordinate point ({0} {1}) lies at the origin.\n\n",co1,co2);
}
}
Sample Output:
Find the quadrant in which the coordinate point lies: ------------------------------------------------------ Input the value for X coordinate :0 Input the value for Y coordinate :0 The coordinate point (0 0) lies at the origin.
Flowchart:
C# Sharp Practice online:
Contribute your code and comments through Disqus.
Previous: Write a C program to find the largest of three numbers.
Next: Write a C program to find the eligibility of admission for a professional course based on the following criteria.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework