title: Drawing a triangle with a loop using 4 integer inputs
body: <p>I have a loop that prints a 25 x 25 grid and is supposed to draw a triangle using 2 x-coordinates and 2 y-coordinates from user input where x1 &lt; x2 and y1 &lt; y2.  It also uses two characters input by the user to fill the interior and outline the exterior of the shape.  The reason for using 4 coordinates is because the other part of the assignment is supposed to use these inputs to draw a rectangle.  I have the rectangle working perfectly.  </p>
  
  <p>I'm using the same loop to print the grid for both shapes, but I cannot figure out how to adjust the if statements that determine the placement of the two characters to make a triangle.</p>
  
  <p>Here is the loop for the triangle.  The if statements in the middle draw a rectangle.  Any ideas on adjustments to make it print a triangle instead?</p>
  
  <pre><code>void Triangle::printTriangle()
  {
  int numrows = 25;
  int numcols = 25;
  int current_row = numrows; // starting row number
  int current_col = 1; // starting col number
  char output = '.';
  
  for(i = 0; i &lt; numrows; i++)        // prints 25 rows of 25 dots 
  {   
  
      cout &lt;&lt; current_row &lt;&lt; '\t';    // Print out current row number, followed by a tab
  
      //This is our loop for each ROW
      //Print out dots in each row OR stuff for the triangle
      for(j = 1; j &lt;= numcols; j++)
      {           
          output = '.'; // Initialize output with our default value of "."
  
  
          if ((current_col &gt;= x1) &amp;&amp; (current_col &lt;= x2) &amp;&amp; (current_row &gt;= y1) &amp;&amp; (current_row &lt;= y2))
          {
              output = outer;
          }
  
          if ((current_col &gt; x1) &amp;&amp; (current_col &lt; x2) &amp;&amp; (current_row &gt; y1) &amp;&amp; (current_row &lt; y2))
          {
              output = inner;
          }
  
          cout &lt;&lt; output &lt;&lt; "  "; // output our "output" value and a space            
          current_col++;  //Increment current column, because this is the end of this column loop iteration
  
      } // Close column loop
  
      cout &lt;&lt; endl;       //...and a new line
  
      current_col = 1;    // reset column count for next iteration
      current_row--;      // decrement current row number
  
  } // Close Row loop
  
  
  //output column labels across bottom line
  cout &lt;&lt; '\t';
  
  // put 1 -&gt; 25 across the bottom
  for (i = 1; i &lt;= 25; i++)
  {
      if(i &lt; 10)
      {
          cout &lt;&lt; i &lt;&lt; "  ";
      }
  
      if(i &gt; 9)
      {
          cout &lt;&lt; i &lt;&lt; " ";
      }
  }
  
  // Spit out a couple of blank lines
  cout &lt;&lt; endl &lt;&lt; endl;
  </code></pre>
  
  <p>}</p>