C Program For Compound Interest
Here’s a C program that calculates the compound interest based on the principal amount, rate of interest, time period, and compounding frequency:
#include
#include
int main() {
// Declare variables
float principal, rate, time, amount, compound_interest;
// Get input from user
printf("Enter principal amount: ");
scanf("%f", &principal);
printf("Enter rate of interest: ");
scanf("%f", &rate);
printf("Enter time in years: ");
scanf("%f", &time);
// Calculate amount
amount = principal * pow((1 + rate / 100), time);
// Calculate compound interest
compound_interest = amount - principal;
// Print compound interest
printf("Compound interest = %f\n", compound_interest);
return 0;
}
Output

This program first declares five variables:
principal
,rate
,time
,amount
, andcompound_interest
. Theprincipal
variable stores the principal amount, therate
variable stores the rate of interest, thetime
variable stores the time in years, theamount
variable stores the amount, and thecompound_interest
variable stores the compound interest.The program then gets input from the user for the principal amount, the rate of interest, and the time in years.
The program then calculates the amount using the formula
amount = principal * pow((1 + rate / 100), time)
.The program then calculates the compound interest using the formula
compound_interest = amount - principal
.The program then prints the compound interest to the console.
You can change the values of the variables in the program to calculate compound interest for different amounts, rates, and times.
SELECT AVG(emp_sal)
FROM employee;
SELECT COUNT(*)
FROM employee;