Computer Science Of Engineering

Simple and practical computer science tutorials, programming guides, and engineering concepts for students and beginners.

Breaking

Friday, April 18, 2025

Finding compound interest in C

 Finding compound interest


Program:



#include <stdio.h>

#include <math.h> // For pow()


int main() {

    double principal, rate, time, amount, compoundInterest;


    // Input

    printf("Enter Principal amount: ");

    scanf("%lf", &principal);


    printf("Enter Annual Rate of Interest (in %%): ");

    scanf("%lf", &rate);


    printf("Enter Time (in years): ");

    scanf("%lf", &time);


    // Compound Interest Calculation

    amount = principal * pow((1 + rate / 100), time);

    compoundInterest = amount - principal;


    // Output

    printf("Compound Interest = %.2lf\n", compoundInterest);

    printf("Total Amount = %.2lf\n", amount);


    return 0;

}

OUTPUT:




No comments:

Post a Comment