title: method giving app crashes due to segmentation fault in c++
body: <p>this simple loop method is unable to run and an error arises <strong>&quot;app crashed&quot;</strong>. when i checked this in an online compiler it gave <strong>'segmentation fault(core dumped)'</strong>-</p>
  <pre><code>string studies(setMatter ch) {
    string a = &quot;LISTEN CAREFULLY!\n&quot;;
    int i = 0;
    while (i &lt;= ch.a.quantity()) {
      a += ch.a.getAns(i);
      i++;
    }
    return a;
  }
  </code></pre>
  <p>also see for reference of methods in the above code-</p>
  <pre><code>class Answer {
   private:
    vector&lt;string&gt; ch;
  
   public:
    void setAns(string ans) { ch.push_back(ans); }
  
    string getAns(int num) { return (ch[num]); }
  
    int quantity() { return ch.size(); }
  };
  </code></pre>
  <p>am i accessing elements out of bond? but i dont know where as i every number starts from 0 in programming</p>