Math, asked by dhruvshadilya7146, 1 year ago

C program to compute simple interest and compound interest

Answers

Answered by Shruti2635
2
This C Program calculates the simple interest given the principal amount, rate of interest and time. The formula to calculate the simple interest is: simple_interest = (p * t * r) / 100 where p is principal amount, t is time & r is rate of interest.

Here is source code of the C program to calculate the simple interest. The C program is successfully compiled and run on a Linux system. The program output is also shown below.

/*

 * C program to find the simple interest, given principal,

 * rate of interest and time.

 */

#include <stdio.h>

 

void main()

{

float principal_amt, rate, simple_interest;

int time;

 

printf("Enter the values of principal_amt, rate and time \n");

scanf("%f %f %d", &principal_amt, &rate, &time);

simple_interest = (principal_amt * rate * time) / 100.0;

printf("Amount = Rs. %5.2f\n", principal_amt);

printf("Rate = Rs. %5.2f%\n", rate);

printf("Time = %d years\n", time);

printf("Simple interest = %5.2f\n", simple_interest);

}

Similar questions