title: C++ creating a histogram with test score in txt file
body: <p>I am new to C++ and I am trying to create a histogram given a txt file that has these scores: 100, 95, 47, 88, 86, 92, 75, 89, 81, 70, 55, 80 what the program needs to do is display a histogram like this:</p>
  
  <pre><code>00s:
  
  10s:
  
  20s:
  
  30s:
  
  40s:*
  
  50s:
  etc...
  </code></pre>
  
  <p>Here is my code below, what I am having trouble with is simply making sure that the * go into each of the corresponding score percentiles i.e 10s,20s,etc...</p>
  
  <p>Code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;fstream&gt;
  #include &lt;vector&gt;
  #include &lt;cmath&gt;
  
  
  using namespace std;
  
  void Print_Hist();
  
  int main() {
   double nums;
  ifstream data("Test_Score.txt");
  if(data.is_open()){
      cout &lt;&lt; "The file is open" &lt;&lt; endl;
  }else{
      cout &lt;&lt; "Check if file exists" &lt;&lt; endl;
  }  
  
  //  Declare vector&lt;double&gt; vecx
  vector&lt;double&gt; vecx;
  //  read data from input file to vector vecx,
  while(data &gt;&gt; nums)
  {
      vecx.push_back(nums);
  }
  
  for (int i=0; i &lt; vecx.size(); i++){
      int num = vecx[i];
  
      if(num &lt; 10){
          cout &lt;&lt; "*" &lt;&lt; endl; 
      }
      else if(num &gt;= 10 &amp;&amp; num &lt; 20){
          cout &lt;&lt; "*" &lt;&lt; endl;
      }
      else if(num &gt;= 20 &amp;&amp; num &lt; 30){
          cout &lt;&lt; "*" &lt;&lt; endl;
      }
      else if(num &gt;= 30 &amp;&amp; num &lt; 40){
          cout &lt;&lt; "*" &lt;&lt; endl;
      }
      else if(num &gt;= 40 &amp;&amp; num &lt; 50){
          cout &lt;&lt; "*" &lt;&lt; endl;
      }
      else if(num &gt;= 50 &amp;&amp; num &lt; 60){
          cout &lt;&lt; "*" &lt;&lt; endl;
      }
      else if(num &gt;= 60 &amp;&amp; num &lt; 70){
          cout &lt;&lt; "*" &lt;&lt; endl;
      }
      else if(num &gt;= 70 &amp;&amp; num &lt; 80){
          cout &lt;&lt; "*" &lt;&lt; endl;
      }
      else if(num &gt;= 80 &amp;&amp; num &lt; 90){
          cout &lt;&lt; "*" &lt;&lt; endl;
      }
      else if(num &gt;= 90 &amp;&amp; num &lt; 100){
          cout &lt;&lt; "*" &lt;&lt; endl;
      }
      else if(num = 100){
          cout &lt;&lt; "*" &lt;&lt; endl;
      }
  
  
  }
  
  }
  
  void Print_Hist(){
      cout &lt;&lt; "00s: " &lt;&lt; endl;
      cout &lt;&lt; "10s: " &lt;&lt; endl;
      cout &lt;&lt; "20s: " &lt;&lt; endl;
      cout &lt;&lt; "30s: " &lt;&lt; endl;
      cout &lt;&lt; "40s: " &lt;&lt; endl;
      cout &lt;&lt; "50s: " &lt;&lt; endl;
      cout &lt;&lt; "60s: " &lt;&lt; endl;
      cout &lt;&lt; "70s: " &lt;&lt; endl;
      cout &lt;&lt; "80s: " &lt;&lt; endl;
      cout &lt;&lt; "90s: " &lt;&lt; endl;
      cout &lt;&lt; "100: " &lt;&lt; endl;
  }
  </code></pre>