title: Need help in basic C++ regarding how to properly loop through part and finding smallest value
body: <p>Hi I'm needing some help. I'm in a intro to programming class and we are using c++.  I am hoping someone can help me with an assignment that was due yesterday (I understand not to expect miracle responses but a girl can always try). </p>
  
  <p>I'm having two problems that I know of. The first is regarding the smallest value. 
  The big one is in trying to make it loop for requirements of three times but not lose out on my total count.  I cannot use arrays or anything I haven't learned yet which is why I've posted this. I've seen similar problems and questions but they have ended up with answers too complex for current progress in class. So here is the problems instructions:</p>
  
  <p>Instructions
  1) Write a program to find the average value, the largest value, and the smallest value of a set of numbers supplied as input from the keyboard. The number of values in the data set must be in the range 0 to 20, inclusive. The user will first enter the number of values in the data set(use variable int Number). Give the user 3 attempts at entering Number in the range given. If the value for Number entered is out of this range, write an error message but continue. If the user does not enter a valid value for Number within the 3 attempts print an error message and terminate the program.</p>
  
  <p>2) Format only the output for the Average value to 3 decimal places when printed.</p>
  
  <p>3) The values in the data set entered as input can be any value positive, negative, or zero.</p>
  
  <p>4) Make the program output readable(see the example below). (Note: that you will notprint out the input values that were entered in this program like you normally are required to do. This is because we have not covered the “tool” needed to do so yet in our studies).</p>
  
  <p>Below will be the output from the execution of your program:
  (using these values in order for the data set -->  <code>19.0   53.4   704.0    -15.2    0    100.0</code>)</p>
  
  <pre class="lang-none prettyprint-override"><code>The largest number:  704
  The smallest number:  -15.2
  The average of the 6 numbers entered: 143.533
  yourName L4p2XX.cpp
  Lab#4 prob 2 XX-XX-12
  </code></pre>
  
  <p>Here is my poor excuse at the solution:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;iomanip&gt;
  using namespace std;
  
  int main()
  {
      double Number = 0, minValue, maxValue, average, total = 0;
      int ct = 0, numCount;
      cout &lt;&lt; "How many numbers would you like to enter? ";
      cin &gt;&gt; numCount;
  
      for(ct = 1; ct &lt;= numCount; ct += 1)
      {    
          cout &lt;&lt; "Enter Value from 0 to 20, inclusive: ";
          cin &gt;&gt; Number;
  
          if(Number &gt; 20|| Number &lt; 0)
              for(int errorCt = 1; errorCt &lt;= 4; errorCt += 1)
              { 
                  if(errorCt == 4)
                  {  
                      cout &lt;&lt; "You have had 3 attempts to enter a valid" &lt;&lt;
                              "number. \nPlease try this program again when you" &lt;&lt;
                              "are able to follow directions.";
                      cout &lt;&lt;"\nLBn\n"&lt;&lt;"L4P2LB.cpp\n"&lt;&lt;"11-05-12\n";
                      return 0;
                  }
                  cout &lt;&lt; Number &lt;&lt; "is not within range.\n" &lt;&lt; 
                          "Please enter a number from 0 to 20: ";
                  cin &gt;&gt; Number;
              } //end for loop
  
          total += Number;
          if(maxValue &lt;= Number)
              maxValue = Number;
          if(Number &lt;= minValue)
              minValue = Number;
      } //end for loop
  
      cout &lt;&lt; "The smallest number entered was " &lt;&lt; minValue &lt;&lt; endl;
      cout &lt;&lt; "The largest number you entered was " &lt;&lt; maxValue &lt;&lt; endl;
      average = total/numCount;
      cout &lt;&lt; setprecision(3) &lt;&lt; fixed &lt;&lt; showpoint &lt;&lt; "You entered " &lt;&lt;
              numCount &lt;&lt; " numbers. The average of these is " &lt;&lt; average;
  
      //Program ID
      cout &lt;&lt;"\n" &lt;&lt; "L4P2LB.cpp\n" &lt;&lt; "11-05-12\n";
      system ("pause");
      return 0;
  } // End main
  </code></pre>
  
  <p>Thank you in advance to anyone who can steer me in the right direction.  Not looking for anyone to do my work I just need help in direction if nothing else or any suggestions as to what to do.  Thanks again. Lynda</p>
  
  <p>Also I need somehow to pause after the third time and exit properly.  If I put the second pause in it won't work so am I missing something obvious there too!</p>