title: Try catch using a function for negative integers
body: <p>So basically I am trying to get it to stop repeating. If I enter numbers correctly it works fine. If I enter negative numbers which are not allowed and needs a try-catch exception it keeps repeating and won't stop asking for numbers. 
  All I have is this source file for the code and I am trying to make a function for main. </p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;iomanip&gt;
  #include &lt;string&gt;
  
  using namespace std;
  
  void gcd(int x, int y);
  
  int main()
  {
      int x;
      int y;
      cout &lt;&lt; "Please enter two integer values" &lt;&lt; endl;
      cin &gt;&gt; x;
      cin &gt;&gt; y;
      gcd(x, y);
  
      return 0;
  }
  
  void gcd(int x, int y)
  {
      int gcd;
      int s = 0;
      while (s == 0)
      {
          try
          {
              if (x &lt; 0 || y &lt; 0)
                  throw 1;
              else
              {
                  s == 1;
                  break;
              }
          }
          catch (int x)
          {
              cout &lt;&lt; "Wrong negative input please type in two Positive integers" &lt;&lt; endl;
              cin &gt;&gt; x &gt;&gt; y;
              continue;
          }
      }
      for (int i = 1; i &lt;= x &amp;&amp; i &lt;= y; i++)
      {
          if (x % i == 0 &amp;&amp; y % i == 0)
              gcd = i;
      }
      cout &lt;&lt; "The gcd of x: " &lt;&lt; x &lt;&lt; " and y: " &lt;&lt; y &lt;&lt; " is: " &lt;&lt; gcd &lt;&lt; endl;
  }
  </code></pre>