Simple Interest.
Source Code:/**
* C program to calculate simple interest
*/
#include <stdio.h>
int main()
{
float principle, time, rate, SI;
/* Input principle, rate and time */
printf("Enter principle (amount):\n ");
scanf("%f", &principle);
printf("Enter time:\n");
scanf("%f", &time);
printf("Enter rate:\n");
scanf("%f", &rate);
/* Calculate simple interest */
SI = (principle * time * rate) / 100;
/* Print the resultant value of SI */
printf("Simple Interest = %f", SI);
return 0;
}
Output Console:
Logic:
Step by step descriptive logic to calculate simple interest.
- Input principle amount in some variable say principle.
- Input time in some variable say time.
- Input rate in some variable say rate.
- Find simple interest using formula
SI = (principle * time * rate) / 100
. - Finally, print the resultant value of SI.
No comments:
Post a Comment