class_notes7

# The formula for compound interest is a p 1 rn where p

This preview shows page 1. Sign up to view the full content.

This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: annually). Write a program that asks the user to enter the initial investment amount (also called the principle) and the interest rate and then outputs a table showing the amount in the account at the end of each of the first 10 years. The formula for compound interest is: a = p (1 + r)n where p is the principle r is the annual interest rate n is the number of years a is the amount in the account after n years The function pow(x,y) calculates xy Sample output for this program is shown on the next page. Program Output: Compound Interest % a.out Enter the principle amount: 1200.00 Enter the annual interest rate: .04 Year 1 2 3 4 5 6 7 8 9 10 % Amount in account 1248.00 1297.92 1349.84 1403.83 1459.98 1518.38 1579.12 1642.28 1707.97 1776.29 Example Program: Compound Interest 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 /* calculating compound interest */ #include <stdio.h> #include <math.h> int main() { double amount; double principle; double rate; int year; printf( "\nEnter the principle amount: " ); scanf( &q...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online