Question: I'm a learner of C++ and I'm currently making my assignment and I can't seem to update my value.

It's a must to use define for the balance:

```
    #define balance 5000.00

```

In the end of the statement I can't seem to able to update my balance:

```
    printf("Deposit Successful!\nYou have deposited the following notes : \n");
    printf("RM100 x %d = RM %.2f\n",nd100,td100);
    printf("RM 50 x %d = RM %.2f\n",nd50,td50);
    printf("RM 20 x %d = RM %.2f\n",nd20,td20);
    printf("RM 10 x %d = RM %.2f\n\n",nd10,td10);
    dtotal=td100+td50+td20+td10;
    printf(" TOTAL     = RM %.2f\n\n",dtotal);
    newbalance=5000+dtotal;
    printf("Your current balance is RM %.2f\n\n",newbalance);

```

I want to update my `newbalance` to become my balance so that I can continue with my Withdrawal.
I can show a bit of my Withdrawal

```
    printf("\nWithdrawal Successful!\n");
    printf("%d notes x RM 50 = RM%d.00\n",wnotes,wamount);
    printf("Your current balance is RM %.2f\n\n",newbalance);

```

Please do give me some suggestions.

Answer: 
`#define`s are directives to the so called preprocessor. This is transforming the source code of your programm by textual substitution before it is actually compiled.

When you write something like:

```
#define value 42;
printf("%d", value);

```

then the compiler effectively sees

```
printf("%d", 42);

```

This happens completely at (or better before) compile time and is in no way related to the runtime of the programm, i.e. when it gets executed.

What your looking for are variables, though I'd advise looking for a tutorial or book, since that is a very basic aspect of the language, and explaining everything here is out of the scope of this answer. They allow mutating values during the execution of the programm:

```
int main(int argc, char ** argc) {
 int counter = 0;
 for (; counter < 10; ++counter ) {
  printf("counter is %d\n", counter);
 }
 return 0;
}

```

For the sake of completeness, you actually can change the meaning of a define somewhere in the source code:

```
#undef SOMETHING
#define SOMETHING 21
// for the rest of this TEXT (!) every occurrence
// of SOMETHING will be replaced with 21

```

[Source](https://gcc.gnu.org/onlinedocs/cpp/Undefining-and-Redefining-Macros.html)

Effectively you should see defines as separate language, and not touch them unless you're really knowing what you're doing.

---

**Note:** I used code in this answer that would be fine both for a C and C++ compiler. You state that you're learning C++, but then you shouldn't be using `printf` but rather the facilities of `iostream`, e.g.

```
std::cout << "Hello World" << std::endl;

```
Its class rep, Veron

You should use a variable instead of defining a constant for storing the amount of balance. Since the value must be updated once a transaction has been done.

According to what assignment stated, the initial value of balance is always constant and start with same value, which won't be modified anymore, so

```
#define INITIAL_BALANCE 5000.0

```

In main function, you can declare a non-constant variable and assign the initial balance (value of INITIAL\_BALANCE) to the variable so that you can always update the balance:

```
double balance = INITIAL_BALANCE;

```