2. Function Arguments Specification
Challenge: Banking Transaction Function
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:
- Use the balance as the first positional argument of the function. It must have a
doubletype and be passed by a pointer.
- Set the default value of the second
withdrawalAmountparameter to zero.
- Print the current balance using the
- Check if the
withdrawalAmountvalue is less than your current balance. If it is right, provide withdrawal operation (subtract the appropriate amount from the balance).
- Test the function using 3 different cases. Pass the address of the
accountBalancevariable as the first positional argument of the function.
Everything was clear?