title: How Do I determine if a number is a prime number in array that has 1000 elements in it?
body: <p>I am making a program that determines if a value is composite, Prime, or Unvisited. The program ignores the first two values because they are 0 and 1, and labels them as I for ignore. Instead of outputting numbers it outputs the letter representation. example: "0123456" would output "IIPPCPC". It need to determines all the values up to 1000. The program uses loops to go through the array and change the value to the correct letter that represents it. I am confused on what code I would use to loop through the array and change all the values that are set to P at the moment that are composite to C. The program is suppose to reloop through the code in steps until all the values have be set to the correct representation.</p>
  
  <pre><code>    /*
      / Name: Ralph Lee Stone
      / Description: Uses an array to find all the prime numbers up to 1000.
      / Date: 11/13/2013
      / Project: RLStone3_HW_10
      */
  
      #include &lt;iostream&gt;
      using namespace std;
  
      int main()
      {
  // Declares an array to print all prime numbers up to 1000.
  char mychararray[1001];
  
  // Set all array index values to 'U', which stands for unvisited.
  for(int i = 0; i &lt;= 1000; i++)
  {
  mychararray[i] = 'U';
  }
  
  // Set the first two elements of the array index 0 &amp; 1 to 'I'. which stands for                ignore. 
  mychararray[0] = 'I';
  mychararray[1] = 'I';
  
  //for ( int i = 0 ; i &lt; 1001 ; i ++ )
  //  cout &lt;&lt; mychararray[i] ;
  //cout &lt;&lt; mychararray;
  
      //Skips the first two values, so that the first two values are skipped.
  int i = 0;
  while(mychararray[i] !='U')
      i++;
  
  // Changes the all the values that are set to U to P.
  
  for(int i = 2; mychararray[i] &gt;= mychararray[1001];  i++)
  mychararray[i] = 'P';
  //i++;
  
      // Loops through the array again and changes all the values that are set to P that are composite to C.
  
      // Outputs the array.
  for ( int i = 0 ; i &lt; 1001 ; i ++ )
      cout &lt;&lt; mychararray[i] ;
  
  //Pauses the console window.
  system("pause");
  
  // returns the value 0.
  return(0);
      }
  </code></pre>