title: check if array element value already existed when user input
body: <p>How do i check if array already contains a value?</p>
  
  <p>for example, 
  Input:1
  Output:1</p>
  
  <p>Input:1
  Error!: Number existed</p>
  
  <p>Input:2
  Output:2</p>
  
  <p>When the user input already existed in the array, it will show error and ask them to input again, until they entered a different value. when a different value is entered, that value will be added to array. if the value entered is same as any element value, it will not be added to the array.</p>
  
  <pre><code>int num[5], temp;
  bool val = true, existed = false;
  
  for(int i = 0; i &lt; 5; i++){
      val = true;
  
          while(val){
  
              cout &lt;&lt; "\nPlease enter a number:";
              cin &gt;&gt; temp;
  
              for(int x = 0; x &lt; 5; x++){
                  if(temp == num[x]){
                      existed = true;
                  }
              }
  
              if(existed){
                  cout &lt;&lt; "Number existed";
              } else {
                  num[i] = temp;
                  cout &lt;&lt; "Your number" &lt;&lt; num[i];
                  val = false; 
              }
          } 
  
  }
  </code></pre>