/**
* C program to calculate Compound Interest
*/
#include"stdio.h"
#include "math.h"
int main()
{
float principle, rate, time, CI;
// Read 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) - 1);
// Print the resultant CI
printf("Compound Interest = %f", CI);
return 0;
}
Enter principle (amount): 1500
Enter time: 2
Enter rate: 6.6
Compound Interest = 204.533997
Press any key to continue . . .
"Exploring the C Program to Calculate Compound Interest"
Importing Required Libraries
Main Function
Declaration of Variables
Reading Input
Calculating Compound Interest
Displaying Result
Return Statement
"In conclusion, the C program to calculate compound interest is a simple yet useful program for students, financial analysts, and researchers. The program is easy to understand and can be used to calculate compound interest for various scenarios.
First read the algorithm, then study the program code line by line. After that, compare the code with the output and finally go through the explanation. This approach helps learners understand both the logic and the implementation properly.
After understanding this example, try to rewrite the same program without looking at the code. Then change some values or logic and run it again. This helps improve confidence and keeps learners engaged on the page for longer.