Compound Interest in c language
C Program To Calculate Compound Interest
You need to know :
- Arithmetic operators.
- Data type.
- BODMAS rule. // To know precedence of an operator.
- Basic input and output system.
Formula Of Compound Interest :
Compound Interest = Principle * (1 + Rate / 100 )^T
or
ci = p * pow ( ( 1 + r / 100 ) , t )
Wondering what is pow!! We got it covered, click here.
Tips To Do The Program :
- Take input of principle amount from user. store in a variable like principle.
- Do same from Time and Rate. Store it in some appropriate variables like time and rate.
- Now calculate the Compound Interest using the above formula and store it in a variable say ci.
- Lastly, show the value of ci to the user.
- Don't forget to optimize the program for a good look and output.
Code :
#include<stdio.h>
#include<math.h>
void main()
{
float p,t,r,ci;
printf("Enter the principle amount : ");
scanf("%f",&p);
printf("Enter the rate : ");
scanf("%f",&r);
printf("Enter the time period : ");
scanf("%f",&t);
ci = p * pow((1+r/100),t);
printf("\n\n The compound interest is : %f",ci);
}
Output :
Enter the principle amount: 1200
Enter the rate: 5.4
Enter the time period: 2
Compound Interest = 1335.433105
Comments
Post a Comment
Give your feedback!
DO NOT SPAM !!
NO THIRD PARTY PROMOTIONAL LINK !!!! (else comment will be deleted.)