title: C++ Program to Display Numbers Between Two Intervals Check Whether a Number can be Express as Sum of Two Prime Numbers
body: <p>i wrote a  Program to Display Numbers Between Two Intervals and Check Whether can be Express as Sum of Two Prime Numbers</p>
  
  <p>This is my code</p>
  
  <pre><code>//============================================================================================
  // Check whether and display a number between two intervals can be expressed as 2 prime number                                                           
  //============================================================================================
  #include&lt;stdio.h&gt;
  #include&lt;iostream&gt;
  #include&lt;math.h&gt;
  using namespace std;
  
  int checkPrime (int);
  int main()
  {
      int n1 , n2 , i , j;
      bool flag = false;
      cout &lt;&lt; "Enter two number to check:" &lt;&lt; endl;
      cin &gt;&gt; n1 &gt;&gt; n2 ;
      for (i = n1 ; i &lt;= n2 ; i++)
      {
          for (j = 2 ; j &lt;= i/2 ; j++ )
          {
              if(checkPrime (j) &amp;&amp; checkPrime (i-j))
              {
                  cout &lt;&lt; "Number " &lt;&lt; i &lt;&lt; " equal sum of two prime number " &lt;&lt; j &lt;&lt; " + " &lt;&lt; i - j &lt;&lt; endl;
                  flag = true;
              }                       
          }
          if (flag == false)
              {
                  cout &lt;&lt; "Number " &lt;&lt; i &lt;&lt; " can't epress to sum of two prime number " &lt;&lt; endl;
              }
      }           
      system ("pause");
      return 0;
  }
  
  int checkPrime (int n)
  {
      bool flag = true;
      for (int i = 2; i &lt;= n/2; i++)
      {
          if (n % i == 0)
          {
              flag = false;
              break;          
          }       
      }
      return flag;
  }
  </code></pre>
  
  <p>Out put
  Enter two number to check:<br>
  1<br>
  12                                                                                                                                                                                                        </p>
  
  <pre><code>Number 1 can't epress to sum of two prime number                                                                                                                                                          
  Number 2 can't epress to sum of two prime number                                                                                                                                                          
  Number 3 can't epress to sum of two prime number                                                                                                                                                          
  Number 4 equal sum of two prime number 2 + 2                                                                                                                                                              
  Number 5 equal sum of two prime number 2 + 3                                                                                                                                                              
  Number 6 equal sum of two prime number 3 + 3                                                                                                                                                              
  Number 7 equal sum of two prime number 2 + 5                                                                                                                                                              
  Number 8 equal sum of two prime number 3 + 5                                                                                                                                                              
  Number 9 equal sum of two prime number 2 + 7                                                                                                                                                              
  Number 10 equal sum of two prime number 3 + 7                                                                                                                                                             
  Number 10 equal sum of two prime number 5 + 5                                                                                                                                                             
  Number 12 equal sum of two prime number 5 + 7
  </code></pre>
  
  <p>Number 11 is missing :-s and i dont know why :( pls help me to fix it</p>