Compound interest
hello Reader,
This is the simple program in which we can calculate Compound Interest, where any user can give any value to it.
#include<stdio.h> //standard library function
#include<conio.h>
int main()
{
int i,N; // define variables
float P,R,sum=1,CI; //define variables
printf("enter price\n"); //print what price user want to enter
scanf("%f",&P);
printf("enter rate\n"); //print what rate user want to enter
scanf("%f",&R);
printf("enter year\n"); //print for how many years user want to enter
scanf("%f",&N);
for(i=1;i<=N;i++) //for loop from 1-N no
{
sum=sum*(1+(R/100)); // formula for calculating sum
}
CI=P*(sum-1); //calculating Compound Interest
printf("compound interest=%f",CI); //display the Compound Interest
getch();
return 0;
}
This is the simple program in which we can calculate Compound Interest, where any user can give any value to it.
#include<stdio.h> //standard library function
#include<conio.h>
int main()
{
int i,N; // define variables
float P,R,sum=1,CI; //define variables
printf("enter price\n"); //print what price user want to enter
scanf("%f",&P);
printf("enter rate\n"); //print what rate user want to enter
scanf("%f",&R);
printf("enter year\n"); //print for how many years user want to enter
scanf("%f",&N);
for(i=1;i<=N;i++) //for loop from 1-N no
{
sum=sum*(1+(R/100)); // formula for calculating sum
}
CI=P*(sum-1); //calculating Compound Interest
printf("compound interest=%f",CI); //display the Compound Interest
getch();
return 0;
}
0 comments:
Post a Comment