Challenge.2_C Program To Find Simple Interest

     Hey Folks! This is the solution post for challenge.2_C Program To Find Simple Interest.

C program to find simple interest

  • LOGIC :

Since we know that the simple interest of any amount is calculated by : S.I = P*R*T / 100. So we'll first take input of principle amount, rate and time period by user and then we'll calculate the S.I by the formula.

  • ALGORITHM :
  1. Start
  2. Declare variables for principle amount(p), rate(r), and time(t).
  3. Take input from user for p,r and t.
  4. Calculate S.I = (p*r*t)/100
  5. Print p, r, t and S.I
  6. End
  • CODE :
#include <stdio.h>

int main ()
{
    //declare variables
    float p,r,t;
    printf("Enter amount, rate and time respectively : ");
    //input amount, rate, time
    scanf("%f %f %f",&p,&r,&t);

    //calculate Simple Interest
    float si=(p*r*t)/100;
    //print input data
    printf("Principle amount : %.2f",p);
    printf("\nRate : %.2f",r);
    printf("\nTime : %.2f",t);

    //print Simple Interest
    printf("\nSimple interest : $%.2f",si);

    return 0;
}

 

  • OUTPUT :

Enter amount, rate and time respectively : 3000 0.35 5
Principle amount : 3000.00
Rate : 0.35
Time : 5.00
Simple interest : $52.50

 

That's all for today. If you get any problem then don't hesitate to ask.

If the post was helpful, then 

Share, Subscribe and keep Coding...

 

Comments