C program, algorithm, flowchart & explanation of the program that calculates the Simple Interest and Compound Interest. The Principal, Amount, Rate of interest and Time are entered through the keyboard.

Total interest and compound interest in c flowchart display picture

Write a C program to calculates the Simple Interest and Compound Interest. The Principal amount, Rate of interest and Time are entered through the keyboard:-

Here, we have to write a simple C program that calculates the Simple Interest and Compound Interest. The user will enter the Principal amount, Rate of interest, and Time.

Formulae used:-

Simple interest=(p*r*t)/100

where, p= Principal amount

r= Rate of interest

t= Time of investment.

Compound interest= p*(1+r/100)^t        (assumption taken only one-time interest got compounded annually)

Explanation & Program code:-

We will ask the user to enter the value of the principal amount, rate of interest, and time of investment then we will store the entered value into the variables named p,r, and t respectively. Based on the entered radius value, we will calculate the simple interest and compound interest. To make the program code easier we have taken the assumption that only one-time interest gets compounded annually(in the question mentioned take the value of p, r, t from the user). Further details are mentioned as comments in the program code.

C
#include <stdio.h>
#include <math.h>
main()
{
    float p,r,t,si,ci,tsi,tci;                                   /* Decleration of variable */
    printf("Enter initial amount:-");                           
    scanf("%f",&p);
    printf("Enter rate of interest per anum:-");                 /*Taking input from user*/
    scanf("%f",&r);                                              
    printf("Enter no of years the money is invested:-");
    scanf("%f",&t);                                             
    si=(p*r*t)/100;                                              /* Simple interest calculation*/
    printf("Simple interst:-%.2f\n",si);
    tsi=si+p;                                                    /*Calculation of total simple interest with principal amount*/
    printf("Total amount with interest:-%.2f\n",tsi);
    ci=p*pow(1+r/100,t)-p;                                       /* Compound interest calculation*/
    printf("Compound interest:-%.2f\n",ci);
    tci=ci+p;                                                    /*Calculation of total compound interest with principal amount*/
    printf("Total amount with compound interest:-%.2f",tci);
    return 0;
}

Output:-

C
Enter initial amount:-12500
Enter rate of interest per anum:-12
Enter no of years the money is invested:-8
Simple interst:-12000.00
Total amount with interest:-24500.00
Compound interest:-18449.54
Total amount with compound interest:-30949.54

Algorithm of the program to calculate Simple interest and compound interest:-

Step 1:- Start.
Step 2:- Declaration of variables.
Step 3:- Read principle amount, rate of interest, time of investment.
Step 4:- Simple interest=(p*r*t)/100 and total amount with S.I=Simple interest + principal amount.
Step 5:- Print Simple Interest and Total amount with simple interest.
Step 6:- Compound interest= p*(1+r/100)^t and total amount with C.I=C.I+principal amount.
Step 7:- Print Compound interest and total amount with compound interest.
Step 8:- Stop.

Flowchart of the program to calculate the Simple interest and Compound interest:-

Total interest and compound interest in c flowchart

As you have reached the end of the article, so I hope as of now you have a clear understanding of the program, algorithm, and flowchart to calculate the Simple interest and compound interest. Please let me know your queries, suggestion, and feedback in the comment section.

Leave a Comment

Your email address will not be published.