title: How to reset all variables in C++?
body: <p>My code seems to be functioning without any problems,<br>
  but our professor warned us that this task might require<br>
  resetting of variables in order to rerun cleanly after first run.</p>
  
  <p>Problem is I have no idea how to reset variables and<br>
  I assume it becomes essential with more complex code. Help?  </p>
  
  <p>This weather task is basically "ask the user which month it is,<br>
  then ask for min.temperature, max.temp. &amp; rainfall for each day of this month,<br>
  then print monthly averages and total rainfall.</p>
  
  <pre><code>// Note to Stackoverflowers: Dager = days &amp; Nedbor = rainfall.
  // Other then that everything below is translated to english just for this
  // question
  #include &lt;iostream&gt;
  #include &lt;iomanip&gt;
  using namespace std;
  
  int main() {
    char rerun = 'j';  // rerun program variable
    while (rerun == 'j' || rerun == 'J')  // rerun program
    {
      int antDager, antD;  // number of days
      int minTemp;
      float minTempAdd = 0;  // min.temp.
      int maxTemp;
      float maxTempAdd = minTempAdd;  // max.temp
      int mmNedbor;
      float mmNedborAdd = 0;  // rain/downfall
  
      do {
        cout &lt;&lt; "\n\tHow many days in this month? (28 til 31)\n";  //#days?
        cin &gt;&gt; antDager;
        if (31 &lt; antDager || 28 &gt; antDager)  // must be 28-31
        {
          cout &lt;&lt; "\n\tInvalid value\n";
        }
      } while (31 &lt; antDager || 28 &gt; antDager);  // loop if invalid value
  
      for (antD = 1; antD &lt; antDager;
           antD++,  // for loop the month
           minTempAdd += minTemp, maxTempAdd += maxTemp,
          mmNedborAdd +=
           mmNedbor) {  // the above increments temperatures and rain with itself
        do {
          cout &lt;&lt; "\n\tminTemp? (-70 til 70), max.temp? (min til 70),   
              rain in mm
              ? (0 til 200)\n ";      //sentence break for this website
                    cin &gt;&gt;
                    minTemp &gt;&gt; maxTemp &gt;&gt;
                    mmNedbor;  // temperatures and rain input
          if ((-70) &gt; minTemp || 70 &lt; minTemp) {
            cout &lt;&lt; "\n\tInvalid min-value\n";
          }
          if (minTemp &gt; maxTemp || 70 &lt; maxTemp) {
            cout &lt;&lt; "\n\tInvalid max-value\n";
          }
          if (0 &gt; mmNedbor || 200 &lt; mmNedbor) {
            cout &lt;&lt; "\n\tInvalid Nedbor-value\n";
          }
        } while ((((-70) &gt; minTemp || 70 &lt; minTemp) ||
                  (minTemp &gt; maxTemp || 70 &lt; maxTemp)) ||
                 (0 &gt; mmNedbor || 200 &lt; mmNedbor));
      }
  
      cout &lt;&lt; "\n\tGjennomsnittlig minTemp: " &lt;&lt; minTempAdd / antDager;
      cout &lt;&lt; "\n\tGjennomsnittlig minTemp: " &lt;&lt; maxTempAdd / antDager;
      cout &lt;&lt; "\n\tGjennomsnittlig nedbor: " &lt;&lt; mmNedborAdd / antDager;
      cout &lt;&lt; "\n\tTotal nedbor: " &lt;&lt; mmNedborAdd &lt;&lt; endl;
  
      cout &lt;&lt; "\n\tØnsker du å kjøre programmet igjen? j/n";
      cin &gt;&gt; rep;
      if (rerun == 'n' || rerun == 'N') {
        cout &lt;&lt; "\n\tExiting program\n";
      }
    }
  
    return 0;
  }
  </code></pre>
  
  <p>EDIT:<br>
  I get some feedback on lack of initialization (I assume that means defining variables). I've tried not to do that. My prof. asked us to "use const as much as possible and "hardcoded" variables minimally.<br>
  I couldn't find any use of const here so I compensated with minimum "hardcording", I hope he was talking about initialization.</p>