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 /* for the pow function */ Using the challenge template above, just fill in the missing code sections that start with "TODO" just like you did for the minimum assignment. The template code will compile without any changes, but your job is to add the missing code to get everything to work. Good Luck!

/***************************************************************** ** 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!