title: Is there any way to print following pattern without using nested loops?
body: <p>This image contains a pattern. The '*' is getting subtracted and '-' being added.</p>
  <p><a href="https://i.stack.imgur.com/B94Qh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/B94Qh.png" alt="" /></a></p>
  <p>Where I am confused that I am not allowed to use nested loop. I don't know why it confused me.</p>
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  int main(){
      string a=&quot;*&quot;;
      for (int i=0; i&lt;4; i++){
          cout&lt;&lt;a&lt;&lt;endl;
          a=a+&quot;*&quot;;
      }
  }
  </code></pre>
  <p>I tried this code to test to print the pattern which successfully it did. Following was the pattern made by it.</p>
  <pre><code>*
  **
  ***
  ****
  </code></pre>
  <p>This seems fine because C++ allowed <code>a=a+&quot;*&quot;</code> which was addition of string into string data. But the pattern I require is</p>
  <pre><code>****
  ***-
  **--
  *---
  </code></pre>
  <p>In it, the '-' can be added but how can I subtract '*'. I can't do <code>a=a-'*'</code>. Do I need to use indexes of the string? But only one loop is allowed.</p>