Dr. A.P.J. Abdul Kalam Technical University, Lucknow
KCS101 / KCS201 Programming for Problem Solving - Using C Language
Lab Exercises
2. Write a program that calculates the Simple Interest and Compound Interest. The Principal Amount, Rate of Interest, and Time are entered through the Keyboard.
/*
File: Prgrm02.c
Author: Aditya Saini
Date: Sept 06, 2019
Description: Program to find Simple Interest and Compound Interest.
*/
#include <stdio.h>
#include <math.h>
#include <math.h>
int main (void)
{
float principal_amount;
float rate_of_interest;
float time_in_years;
float simple_interest;
float compound_interest;
//Input Principal Amount, Rate of Interest and Time (in years).
printf ("Input Principal Amount: ");
scanf ("%f", &principal_amount);
float rate_of_interest;
float time_in_years;
float simple_interest;
float compound_interest;
//Input Principal Amount, Rate of Interest and Time (in years).
printf ("Input Principal Amount: ");
scanf ("%f", &principal_amount);
printf ("Input Rate of Interest: ");
scanf ("%f", &rate_of_interest);
scanf ("%f", &rate_of_interest);
printf ("Input Time (Years): ");
scanf ("%f", &time_in_years);
scanf ("%f", &time_in_years);
//Calculate Simple Interest and Compound Interest.
simple_interest = principal_amount * rate_of_interest * time_in_years / 100;
compound_interest = principal_amount * (pow ((1 + rate_of_interest / 100), time_in_years))
- principal_amount;
//Output the result
printf ("Simple Interest: %.2f\n", simple_interest);
printf ("Compound Interest: %.2f ", compound_interest);
compound_interest = principal_amount * (pow ((1 + rate_of_interest / 100), time_in_years))
- principal_amount;
//Output the result
printf ("Simple Interest: %.2f\n", simple_interest);
printf ("Compound Interest: %.2f ", compound_interest);
};
Output
Input Principal Amount: 15000
Input Rate of Interest: 13.50
Input Time (Years): 5
Simple Interest: 10125.00
Compound Interest: 13253.39
Input Rate of Interest: 13.50
Input Time (Years): 5
Simple Interest: 10125.00
Compound Interest: 13253.39
No comments:
Post a Comment
Please do not post spam links.