title: C++ Array with while loop
body: <p>Hi guys please check this code. I want to create a program in which I will be prompted to enter first name and last name then output it in chronological order without having to create variable for each first name and last name.</p>
  
  <pre><code>#include&lt;iostream&gt;
  using namespace std;
  int main(){
  
  int fname[9];
  int lname[9];
  int x;
  
  while (x &lt; 10){
      cout&lt;&lt;"Enter first name: ";
      cin&gt;&gt;fname[0];
      cout&lt;&lt;"Enter last name: ";
      cin&gt;&gt;lname[0];
      x = x + 10;
  }
  
  x = 0;
  
  while (x &lt; 10){
      cout&lt;&lt;fname[0]&lt;&lt;" "&lt;&lt;lname[0]&lt;&lt;"\n";
      x = x + 1;
  }
  
  return 0;
  }
  </code></pre>