write logicto compare two number and check the greatest number and to calculate simple interest
Answers
Answer:
Simple C Program To Find Simple Interest
Example
Input
Enter principle: 1200
Enter time: 2
Enter rate: 5.4
Output
Simple Interest = 129.600006
Required knowledge
Arithmetic operators, Variables and expressions, Data types, Basic input/output
Simple Interest formula
Simple interest formula is given by.
Simple interest formula
Where,
P is the principle amount
T is the time and
R is the rate
Logic to calculate simple interest
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.
Program to calculate simple interest
/**
* 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): ");
scanf("%f", &principle);
printf("Enter time: ");
scanf("%f", &time);
printf("Enter rate: ");
scanf("%f", &rate);
/* Calculate simple interest */
SI = (principle * time * rate) / 100;
/* Print the resultant value of SI */
printf("Simple Interest = %f", SI);
return 0;
}