C program to calculate simple interest using function

write a C program to input principle, rate, and time from the user and find the simple interest using function. C program to calculate simple interest using function.How to calculate simple interest in C .

Formula To find simple interest

Simple Interest = (p * n * r) / 100

where,

            p = Principal Amount,

             n = Number of Years / Period

             r = Rate of Interest

example:-

              Principal Amount = ₹ 5000

              Period = 2 years

              Rate of Interest = 10%

              Simple Interest = ₹ 1000

Logic to calculate simple interest

Step

Input

  1. principle amount in variable P.
  2. time in variable t.
  3. rate in variable r.
  4. Find simple interest using formula.
  5. SI = (p*t*r) / 100
  6. print output.

C program to find simple interest

#include <stdio.h>
int main()
{
    float p, t, r, SI;

     //Input principle, rate and time 
    printf("Enter principle:- ");
    scanf("%f", &p);
    
    printf("Enter time: ");
    scanf("%f", &t);

    printf("Enter rate: ");
    scanf("%f", &r);

    // Calculate simple interest
    SI = (p * t * r) / 100;

    // Print the resultant value of SI
    printf("Simple Interest = %f", SI);
}

 

C program to calculate simple interest
output

C program to calculate simple interest using function

#include <stdio.h>
float simple_interest(float p,float t,float r)
{
	// Calculate simple interest
  
    return ((p * t * r) / 100);
}
int main()
{
    float p, t, r, SI;

     //Input principle, rate and time 
    printf("Enter principle:- ");
    scanf("%f", &p);
    
    printf("Enter time: ");
    scanf("%f", &t);

    printf("Enter rate: ");
    scanf("%f", &r);
    
    SI=simple_interest(p,t,r);

    // Print the resultant value of SI
    printf("Simple Interest = %f", SI);
}
C program to calculate simple interest using function
output

 

C++ program to calculate simple interest using function

java program to calculate simple interest using function

c# program to calculate simple interest using function

python program to calculate simple interest using a function

Leave a Reply

Your email address will not be published. Required fields are marked *