Formula to find the compound amount
Where,
P = principle
R = rate
T = time
C program to print compound amount
| #include<stdio.h> #include<conio.h> #include<math.h> void main() { float p, r, t, ca, a, b, c; // taking value of principle, rate and interest from the user printf("\n Enter the value of principle, rate and time"); scanf("%f%f%f", &p, &r, &t); a=r/100; //performing rate/100 b=1+a; // performing (1+r/100) c=pow(b,t); // performing (1+r/100)t ca=p*c; // performing p*(1+r/100)t printf("\n Compound Amount is %f", ca); getch(); } |
Output
C program to calculate compound amount without using pow()
| #include<stdio.h> #include<conio.h> void main() { float p, t, r, i, z=1, ca, a, b; // taking input from the user printf("\n Enter the value of principle, rate and time"); scanf("%f%f%f", &p, &t, &r); a = r/100; // performing r/100 b = (1+a); // performing (1+r/100) for(i=1;i<=t;i++) { // to perform (1+r/100) z=z*b; // b is varible where value of (1+r/100) stored } ca = p*z; // value of (1+r/100) store in z printf("\n Compound Amount is %f", ca); getch(); } |
Output
C program to calculate compound amount using function
| #include<stdio.h> #include<conio.h> #include<math.h> void ci(float,float,float); // function prototype int main() { float p, r, t; // taking value of principle, rate and interest from the user printf("\n Enter the value of principle, rate and time"); scanf("%f%f%f", &p, &r, &t); ci(p,r,t); // function call getch(); } void ci(float p, float r, float t) { float a, b, c, ca; a=r/100; //performing rate/100 b=1+a; // performing (1+r/100) c=pow(b,t); // performing (1+r/100)t ca=p*c; // performing p*(1+r/100)t printf("\n Compound Amount is %f", ca); getch(); } |
Output





0 Comments
Please do not enter any spam link on comment box