title: how to loop over vector size C++
body: <p>I am new to C++ programming and have a question about Vector size and for loops.</p>
  
  <p>Let's say that my Vector size is 3 containing the values:</p>
  
  <pre><code>x = [Susan 13, Female, Chicago Illinois] //this will be the comparison point
  y = [Sally 18, Female, Tokyo Japan]     
  z = [Rowland 2, Male, Arizona California] //y &amp; z will be compared to x
  +...other vectors depending on how many the user inputs
  </code></pre>
  
  <p>I want to create a for loop that will generate each of the ages by comparing y &amp; z to x. So I want it to be like</p>
  
  <pre><code>x[0] - y[0] --&gt; 5  //difference of the ages
  x[0] - z[0] --&gt; 11
  </code></pre>
  
  <p>So far, I have this:</p>
  
  <pre><code>vector&lt;string&gt; age, gender, location;
  
  void ageDiff(vector&lt;string&gt; a, vector&lt;string&gt; g, vector&lt;string&gt; l){
       //i want to start calculating the age differences but i'm not sure how to loop depending on how many data the user inputs
  }
  
  int main(){
      int n;
      std::cout &lt;&lt; "How many data will you input? ";
      std::cin &gt;&gt; n;
  
      for (a=0;a&lt;n;a++){
          std::cout &lt;&lt; "Please enter the data for person #" &lt;&lt; a;
          std::cin &gt;&gt; a;
          std::cin &gt;&gt; b;
          std::cin &gt;&gt; c;
          age.push_back(a);
          gender.push_back(b);
          location.push_back(c);
  
      for (a=0;a&lt;(age.size()-1);a++){
          ageDiff(age, gender, location)
      }
  </code></pre>