Problem statement
Write a program to calculate simple interest and compound interest.
Here we will take principle, time and rate of as input from user.
What is compound interest
The concept of compound interest is that interest is added back to the principal sum so that interest is earned on that added interest during the next compounding period.
The formula for calculating compound interest is:
= [P (1 + i)n] – P
= P [(1 + i)n – 1]
Where
P = Principal,
i = annual interest rate in percentage terms,
n = number of compounding periods.
What is simple interest
Simple interest is a quick method of calculating the interest charge on a loan. Simple interest is determined by multiplying the daily interest rate by the principal by the number of days that elapse between payments.
The formula for calculating compound interest is:
Simple Interest = Interest Rate x Principal Balance
What is Principle
Principal is the money used to pay down the balance of the loan.
The principal is the amount you are borrowing, and the interest is the charge for the time you have the loan.
What is Interest
Interest is the charge paid to the lender for the privilege of borrowing the money.
Interest is calculated on the principal.
Program to calculate the interest
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18

#include<stdio.h> #include<math.h> int main() { int p,t; float r,si,amount,ci; printf("Enter principal,time and rate of interest\n"); scanf("%d%d%f",&p,&t,&r); //calculating simple interest si=p*t*r/100; printf("Simple interest is = %f\n",si); //calculating compound interest amount=p*pow((1 +r/100),t); ci=amountp; printf("Compound interest = %f",ci); } 
Output:

Enter principal,time and rate of interest 2154 2 4 Simple interest is = 172.320007 Compound interest = 175.766113 