C Programming Code Examples C > Beginners Lab Assignments Code Examples C program to calculate Compound Interest C program to calculate Compound Interest Write a C program to input principle (amount), time and rate (P, T, R) and find Compound Interest. How to calculate compound interest in C programming. Logic to calculate compound interest in C program. Input principle amount. Store it in some variable say principle. Input time in some variable say time. Input rate in some variable say rate. Calculate compound interest using formula, CI = principle * pow((1 + rate / 100), time). Finally, print the resultant value of CI. #include <stdio.h> #include <math.h> int main() { float principle, rate, time, CI; /* Input principle, time and rate */ printf("Enter principle (amount): "); scanf("%f", &principle); printf("Enter time: "); scanf("%f", &time); printf("Enter rate: "); scanf("%f", &rate); /* Calculate compound interest */ CI = principle* (pow((1 + rate / 100), time)); /* Print the resultant CI */ printf("Compound Interest = %f", CI); return 0; }