#include <stdio.h>
#include <math.h> // for pow() function
int main() {
float principal, rate, time;
float simple_interest, compound_interest;
// Taking input
printf("Enter Principal amount: ");
scanf("%f", &principal);
printf("Enter Rate of Interest (in %%): ");
scanf("%f", &rate);
printf("Enter Time (in years): ");
scanf("%f", &time);
// Calculating Simple Interest
simple_interest = (principal * rate * time) / 100;
// Calculating Compound Interest
compound_interest = principal * (pow((1 + rate / 100), time)) - principal;
// Displaying results
printf("\nSimple Interest = %.2f", simple_interest);
printf("\nCompound Interest = %.2f", compound_interest);
return 0;
}
Comments
Post a Comment