Challenge: Banking Transaction FunctionChallenge: Banking Transaction Function

Task

Let's design a function to simulate a bank transaction! This function handles the operation of withdrawing money. The user's current balance is passed as the first argument through a pointer, and the second argument represents the amount to be withdrawn. The second argument defaults to zero if the user only wants to check the balance.

Your objective is to:

  1. Use the balance as the first positional argument of the function. It must have a double type and be passed by a pointer.
  2. Set the default value of the second withdrawalAmount parameter to zero.
  3. Print the current balance using the cout function.
  4. Check if the withdrawalAmount value is less than your current balance. If it is right, provide withdrawal operation (subtract the appropriate amount from the balance).
  5. Test the function using 3 different cases. Pass the address of the accountBalance variable as the first positional argument of the function.

Everything was clear?

Section 2. Chapter 3
toggle bottom row