title: c++ validation login code
body: <p>i am trying to make a simple validation user name and password for my program.
  i am not sure whats wrong with my code, but i think i have some logic error</p>
  
  <p>here is my piece of code</p>
  
  <pre><code>          string usernameinput,passinput;
  string username[]={"mmm","nnnn","rrrr","aaa"};
  string password[]={"1234","1212","1234","1212"};
  bool flag=false;
  
  while(flag==false){
    cout &lt;&lt; "username: "&lt;&lt;endl;
      cin&gt;&gt;usernameinput;
      cout &lt;&lt; "password: "&lt;&lt;endl;
          cin&gt;&gt;passinput;
          for(int i=0;i&lt;=3;i++){
              if(usernameinput ==username[i] &amp;&amp; passinput==password[i] )
              {
                  flag=true;
              }
              else if (usernameinput !=username[i] &amp;&amp; passinput!=password[i])
              {
                  flag=false;
      cout&lt;&lt;"please enter correct username and password"&lt;&lt;endl;
              }
  
          }
  }
  </code></pre>