title: How to get the minimum and maxium number using pointers in C++
body: <p>I trying to find the minimum and maximum numbers using pointers in C++ but in this code that I get from the video-sharing site gives me the wrong value. when I type 1 2 3 4 5 6 its answer is the minimum is 2 and the maximum is 2.</p>
  <p>Here is my code:</p>
  <pre><code>#include &lt;iostream&gt;
   using namespace std;
  int main()
  {
      int value[6], * maxi, * mini, a;
      cout &lt;&lt; &quot;Enter six numbers with space: &quot;;
      for (int a = 0; a &lt; 6; a++)
          cin &gt;&gt; *(value + a);
      maximum = value;
      minimum = value;
      for (i = 1; i &lt; 6; i++)
      {
          if (*(value + i) &gt; * maximum)
              *maximum = *(value + i);
      }
      for (i = 0; i &lt; 6; i++)
      {
          if (*(value + i) &lt; *minimum)
              *minimum = *(value+ i);
      }
      /* Print variable value with their memory address */
      cout &lt;&lt; &quot;Integer with the Maximum value = &quot; &lt;&lt; *minimum &lt;&lt; &quot;, Address of integer = &quot; &lt;&lt; &amp;maximum  
   &lt;&lt; endl;
      cout &lt;&lt; &quot;Integer with the minimum value = &quot; &lt;&lt; *minimum  &lt;&lt; &quot;, Address of integer = &quot; &lt;&lt; &amp;minimum  
    &lt;&lt; endl;
      return 0;
    }
  </code></pre>
  <p>this is the result of the code</p>
  <p>Enter five (6) numbers separated by a space: 1 2 3 4 5 6</p>
  <p>Integer with the largest value = 2, Address of integer = 00AFF9F4</p>
  <p>Integer with the smallest value = 2, Address of integer = 00AFF9E8</p>