forked from saurav2401/C_Basics
-
Notifications
You must be signed in to change notification settings - Fork 1
/
compound_interest.c
36 lines (26 loc) · 1.24 KB
/
compound_interest.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// This is the program to calculate the compound interest rate .
/* Sample Input :
Enter the principle amount : 1000
Enter the interest rate: 12.5
Enter the time period : 2
Enter number of times interest is compounded yearly : 2
Sample Output :
The simple_interest is : 2761816.500000
*/
#include <stdio.h>
void main()
{
float principle , interest , time ,amount, compound_interest ; // Variable declaration
int n ;
printf("Enter the principle amount :");
scanf("%f",&principle); // Input Principle
printf("Enter the interest rate:");
scanf("%f",&interest); // Input interest
printf("Enter the time period :");
scanf("%f",&time); // Input time
printf("Enter number of times interest is compounded yearly :");
scanf("%d",&n); // Input value of n
amount = principle*pow((1+interest/n),n*time);
compound_interest = amount - principle ; // Calculation of compound interest
printf(" The compound_interest is : %f",compound_interest); // Output
}