title: How to create a program that can overwrite a pre-initialized variable with user inputted data during runtime?
body: <p>I was tasked to create an ATM mock program and my problem is overwriting the money and PIN variables with the information that the user will enter.</p>
  <p>Here it is:</p>
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  void Check(int money) { cout &lt;&lt; &quot;Your current balance is: &quot; &lt;&lt; money &lt;&lt; endl; }
  
  void Deposit(int money) {
    int deposit;
    cout &lt;&lt; &quot;Please enter the amount of cash you wish to deposit.\n&quot;;
    cin &gt;&gt; deposit;
    money += deposit;
    cout &lt;&lt; &quot;Your new balance is: &quot; &lt;&lt; money &lt;&lt; endl;
  }
  
  void Withdraw(int money) {
    int withdraw;
    cout &lt;&lt; &quot;Please enter the amount of cash you wish to withdraw.\n&quot;;
    cin &gt;&gt; withdraw;
    money -= withdraw;
    cout &lt;&lt; &quot;Your new balance is: &quot; &lt;&lt; money &lt;&lt; endl;
  }
  
  void Interest(int money) {
    money += money * 0.05;
    cout &lt;&lt; &quot;Your money with interest is: &quot; &lt;&lt; money &lt;&lt; endl;
  }
  
  void Penalty(int money) {
    if (money &lt; 5000) {
      money -= money * 0.02;
      cout &lt;&lt; &quot;Your penalty is: &quot; &lt;&lt; money &lt;&lt; endl;
    } else
      cout &lt;&lt; &quot;Your account will not incur a penalty because you are above the &quot;
              &quot;minimum threshold.\n&quot;;
  }
  
  void ChangePIN(int PIN) {
    int p;
    cout &lt;&lt; &quot;Enter a new PIN: &quot;;
    cin &gt;&gt; p;
    PIN = p;
    cout &lt;&lt; &quot;Your new PIN is: &quot; &lt;&lt; PIN &lt;&lt; endl;
  }
  
  int main() {
    int money = 5000, PIN = 1234, EPIN;
    cout &lt;&lt; &quot;Enter your PIN (Default PIN is 1234): \n&quot;;
    cin &gt;&gt; EPIN;
    if (EPIN == PIN) {
      int choice;
      cout &lt;&lt; &quot;Welcome!\n&quot;
           &lt;&lt; &quot;1 - Check available balance \n&quot;
           &lt;&lt; &quot;2 - Deposit cash \n&quot;
           &lt;&lt; &quot;3 - Withdraw cash \n&quot;
           &lt;&lt; &quot;4 - Compute for the interest of your account(5%)\n&quot;
           &lt;&lt; &quot;5 - Compute for the penalty of having a balance below 5000 (2%) \n&quot;
           &lt;&lt; &quot;6 - Change your PIN\n&quot;
           &lt;&lt; &quot;7 - Exit\n&quot;
           &lt;&lt; &quot;Your choice: &quot;;
      cin &gt;&gt; choice;
      switch (choice) {
      case 7: {
        break;
      }
        {
        case 1: {
          Check(money);
          break;
        }
        case 2: {
          Deposit(money);
          break;
        }
        case 3: {
          Withdraw(money);
          break;
        }
        case 4: {
          Interest(money);
          break;
        }
        case 5: {
          Penalty(money);
          break;
        }
        case 6: {
          ChangePIN(PIN);
          break;
        }
        }
      }
      return 0;
    }
  }
  </code></pre>
  <p>As you can see I'm pretty much a beginner at this. My problem is the money and PIN have the default values of 5000 and 1234 respectively. Now, I need to make the user be able to change these values but once I use return main() they get assigned the same starting values again, What would be the best workaround for this? I thought of using some sort of accumulator for this but I'd like some advice first.</p>