Learn about C Program to Calculate Simple Interest in the below code example. Also refer the comments in the code snippet to get a detailed view about what’s actually happening.
Contents
C Program to Calculate Simple Interest
SI = P × R × T, where P = Principal, R = Rate of Interest, and T = Time period, is the formula for calculating simple interest. In this case, the rate is expressed as a percentage (r%), which is written as r/100.
Program:
#include<stdio.h>
int main()
{
float p, t, r, interest;
// inputs from user
printf("Enter principal amount(p),
time(t) and rate(r) values: ");
scanf("%f %f %f",&p,&t,&r);
// calculating simple interest
interest = ( p*t*r ) / 100;
// print result
printf("interest = %.2f\n",interest);
return 0;
}
Output:
Enter principal amount, time and rate values: 25000 6 3
interest = 4500.00
Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.
Similar Codes :
C Program to Find Sum and Average of 3 Numbers
C Program to Compute Quotient and Remainder using fmod function