#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:
Include necessary headers:
stdio.hfor input/output operations.math.hfor thepowfunction to calculate the power.
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.
Get user input:
- Prompt the user to enter the principal amount, rate of interest, and time period.
- Use
scanfto read the values from the user.
Calculate compound interest:
- Use the formula
compoundInterest = principal * pow(1 + (rate / 100), time) - principalto calculate the compound interest. - The
powfunction is used to calculate the power of the expression(1 + (rate / 100)).
- Use the formula
Print the result:
- Print the calculated compound interest using
printf.
- Print the calculated compound interest using
Return 0:
- Indicate successful program execution.

Welcome to OnlineGuru2020.blogspot.com, your number one source for all things related to Online Education. We're dedicated to providing you the very best of Digital Education, with an emphasis on E-notes,Download Links in PDF and youtube videos etc
OnlineGuru2020 Founded in [2020] by Sapan Kumar Das (Asst. Proff Ramchandi College Saraipali), OnlineGuru2020.blogspot.com has come a way from its beginnings .When I first started, my passion inspired me to start my own blog, seeing the need for students in lockdown2020
We hope you enjoy our products as much as we enjoy offering them to you. If you have any questions or comments, please don't hesitate to contact us.
Contact Datails:-
Mobile Number:-9826026747
Email:-sapam.online@gmail.com
Sincerely,
Sapan Kumar Das
.
No comments:
Post a Comment