title: Can't figure out how to generate coordinates(x,y) entered by the user
body: <p>Can't figure out how to generate coordinates(x,y) entered by the user and find the closest genareted point to the one that the user has entered.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cmath&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;time.h&gt;//for generating a random number
  using namespace std;
  
  int main()
  {
      int x,k,y,quad,x1,y1;// the variables that we are going to use
      cout &lt;&lt; "Enter the value of x : "&lt;&lt;endl;
      cin &gt;&gt;x;
      cout &lt;&lt; "Enter the value of y : "&lt;&lt;endl;
      cin &gt;&gt;y;
      cout &lt;&lt;"Enter the amount of numbers you want to be generated : "&lt;&lt;endl;
      cin &gt;&gt;k;//how many coordinates to be generated
      srand(time(0));//to make sure that the numbers are random
          for(int i = 0; i &lt; k; i++){
  
          int x = rand() % k;//generate x
          int y = rand() % k;//generate y
          x1 = x;
          y1 = y;
  
          cout &lt;&lt; "(" &lt;&lt; x &lt;&lt; "," &lt;&lt; y &lt;&lt;")"&lt;&lt; "\n\n";
      }
      if (((x1*x1)+(y1*y1))&lt;(x*x)+(y*y)){
          cout &lt;&lt;"("&lt;&lt;x1&lt;&lt;","&lt;&lt;y1&lt;&lt;") is the nearest point to ("&lt;&lt;x&lt;&lt;","&lt;&lt;y&lt;&lt;")"&lt;&lt;endl;
      }
  
      if (x&lt;0 &amp;&amp; y&lt;0){//these are to show in which quadrant are the coordinates
          quad = 3;
      }
      else if(x&lt;0 &amp;&amp;y&gt;0){
          quad = 2;
      }
      else if(x&gt;0 &amp;&amp; y&gt;0){
          quad = 1;
      }
      else if(x&gt;0 &amp;&amp; y&lt;0){
          quad = 4;
      }
      else if(x&lt;0 &amp;&amp; y==0){
          quad = 5;
      }
      else if(y&lt;0 &amp;&amp; x==0){
          quad = 6;
      }
      else if(x&gt;0 &amp;&amp; y==0){
          quad = 7;
      }
      else if(y&gt;0 &amp;&amp; x==0){
          quad = 8;
      }
      switch(quad){
          case 1: cout &lt;&lt;"("&lt;&lt;x&lt;&lt;","&lt;&lt;y&lt;&lt;")"&lt;&lt;"are in the 1st quadrant"&lt;&lt;endl;break;
          case 2: cout &lt;&lt;"("&lt;&lt;x&lt;&lt;","&lt;&lt;y&lt;&lt;")"&lt;&lt;"are in the 2nd quadrant"&lt;&lt;endl;break;
          case 3: cout &lt;&lt;"("&lt;&lt;x&lt;&lt;","&lt;&lt;y&lt;&lt;")"&lt;&lt;"are in the 3rd quadrant"&lt;&lt;endl;break;
          case 4: cout &lt;&lt;"("&lt;&lt;x&lt;&lt;","&lt;&lt;y&lt;&lt;")"&lt;&lt;"are in the 4th quadrant"&lt;&lt;endl;break;
          case 5: cout &lt;&lt;"("&lt;&lt;x&lt;&lt;","&lt;&lt;y&lt;&lt;")"&lt;&lt;"are between the 2nd and 3rd"&lt;&lt;endl;break;
          case 6: cout &lt;&lt;"("&lt;&lt;x&lt;&lt;","&lt;&lt;y&lt;&lt;")"&lt;&lt;"are between the 3rd and 4th"&lt;&lt;endl;break;
          case 7: cout &lt;&lt;"("&lt;&lt;x&lt;&lt;","&lt;&lt;y&lt;&lt;")"&lt;&lt;"are between the 1st and 4th"&lt;&lt;endl;break;
          case 8: cout &lt;&lt;"("&lt;&lt;x&lt;&lt;","&lt;&lt;y&lt;&lt;")"&lt;&lt;"are between the 1st and 2nd"&lt;&lt;endl;break;
          default : cout &lt;&lt;"("&lt;&lt;x&lt;&lt;","&lt;&lt;y&lt;&lt;")"&lt;&lt;"are in the (0,0)"&lt;&lt;endl;break;
  
  
      }
  }
  </code></pre>
  
  <p>I know that the solution is probably simple, but i just couldn't figure it out. I'm freshman in college and i feel pretty retarded 
  for asking questions like this, but this is my last hope.
  Any help will be appreciated.^^ </p>