Course Content
C++ Introduction
C++ Introduction
2. Introduction to Operators
4. Introduction to Program Flow
5. Introduction to Functions
Simple Function Practice
Example of the function with arguments from the previous chapter
function
double convert_usd_to_eur(double usd_amount) { const double exchange_rate = 0.91; double euros = usd_amount * exchange_rate; return euros; }
Task
Swipe to show code editor
Create a function withdraw
that simulates a bank account withdrawal. It accepts the current balance and withdrawal amount as arguments. If the balance is sufficient, deduct the amount and return the new balance. Otherwise, return the original balance.
Solution
solution
Switch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?
Thanks for your feedback!
Section 5. Chapter 4
Simple Function Practice
Example of the function with arguments from the previous chapter
function
double convert_usd_to_eur(double usd_amount) { const double exchange_rate = 0.91; double euros = usd_amount * exchange_rate; return euros; }
Task
Swipe to show code editor
Create a function withdraw
that simulates a bank account withdrawal. It accepts the current balance and withdrawal amount as arguments. If the balance is sufficient, deduct the amount and return the new balance. Otherwise, return the original balance.
Solution
solution
Switch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?
Thanks for your feedback!
Section 5. Chapter 4
Switch to desktop for real-world practiceContinue from where you are using one of the options below