Question: C Programming Start with the code here: http://ideone.com/s1zZoF Can you add and call a function to calculate Compound Interest?? You'll need to use the pow
C Programming
Start with the code here: http://ideone.com/s1zZoF
Can you add and call a function to calculate Compound Interest??
You'll need to use the "pow" function in the C Math Library that will raise a value to a specific power. To use it, you will need to include the math.h file in addition to the stdio.h file (I've added this already to the template). #include
/***************************************************************** ** Function: Calculate_Compound_Interest ** ** Description: Compound Interest is the amount of interest ** calculated by using the formula: ** ** interest = (P * pow (1.0 + r, t)) - P ** ** where P is the principle, r is the rate, and t ** is the time of the investment ** ** This function will return the compound interest ** calculated based upon it being passed the principle, ** rate, and time. ** ** Parameters: Principle - The original principal to start with ** Rate - The rate of interest. If you wanted ** 9.5 percent it would be passed as 0.095 ** Time - The time in years ** ** Returns: Interest - The amount of compound interest earned ** ********************************************************************/ float Calculate_Compound_Interest (float principle, float rate, float time) { /* Challenge Step 1) define a local variable of type float to hold the interest */ float interest; /* Challenge TO DO: Step 2) calculate compound interest earned ... */ /* Set interest variable to the right formula value, see above */ /* Challenge Step 3) return the interest calculated back to the calling function */ return (interest); } /* end Calculate_Compound_Interest */
Challenge Sample Output
The output when both the simple interest function AND the compound interest are called within the challenge assignment would look like this:
Enter your principle value: Enter the rate: For example 9.5 percent would be .095: Enter the period of time of your investment: The total simple interest earned is: $ 2565.00 The total compound interest earned is: $ 3257.06
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
