Write A program to calculate thr compound Interest in c language - .OnlineGuruji

.OnlineGuruji

Provides E-Notes,Video Tutorials And Download Links For Students In hindi

*********************************************************

*********************************************************
********************************************************************************

Breaking

Ramchandicollege Saraipali

Technology Jobs

OnlineGuru Blog मे आपका स्वागत है ब्लॉग से संबन्धित जानकारी के लिए संपर्क करें मो ॰ नम ।-9826026747(सपन कुमार दास) अपने विषय से संबन्धित अपडेट प्राप्त करने के लिए ब्लॉग पे दिये गए Bell Icon को press करें कम्प्युटर,Science,English Grammer से संबन्धित विषय की अधिक जानकारी के लिए हमारे ब्लॉग अथवा यू ट्यूब चैनल को सब्क्राइब करे ..

Friday, September 27, 2024

Write A program to calculate thr compound Interest in c language

 

#include <stdio.h>

#include <conio.h>

#include <math.h>

 Void main() 

{

    float principal, rate, time, compoundInterest;

  clrscr();

  printf("Enter principal amount: ");

    scanf("%f", &principal);

    printf("Enter rate of interest: ");

    scanf("%f", &rate);

    printf("Enter time period (in years): ");

    scanf("%f", &time);

    // Calculate compound interest

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

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

getch();

    }

Output:--

Enter principal amount: 1000

Enter rate of interest: 2

Enter time period (in years): 3

Compound Interest = 61.21

This C program calculates compound interest using the following formula:

Compound Interest = Principal * (1 + (Rate / 100))^Time - Principal

Here's a breakdown of the code:

  1. Include necessary headers:

    • stdio.h for input/output operations.
    • math.h for the pow function to calculate the power.
  2. Declare variables:

    • principal: Stores the principal amount.
    • rate: Stores the rate of interest.
    • time: Stores the time period in years.
    • compoundInterest: Stores the calculated compound interest.
  3. Get user input:

    • Prompt the user to enter the principal amount, rate of interest, and time period.
    • Use scanf to read the values from the user.
  4. Calculate compound interest:

    • Use the formula compoundInterest = principal * pow(1 + (rate / 100), time) - principal to calculate the compound interest.
    • The pow function is used to calculate the power of the expression (1 + (rate / 100)).
  5. Print the result:

    • Print the calculated compound interest using printf.
  6. Return 0:

    • Indicate successful program execution.

No comments:

Post a Comment