C Program to Calculate Simple Interest

C program to calculate simple interest; Through this tutorial, you will learn how to calculate simple interest in c program with the help of function, and normal formula.

Programs to Calculate Simple Interest in C

Let’s use the following algorithm to write a program to calculate simple interest (i = (prn)/100 ) in c:

  • Algorithm to Calculate Simple Interest
  • C Program to Calculate Simple Interest using Formula
  • C Program to Calculate Simple Interest using Function

Algorithm to Calculate Simple Interest

Use the following algorithm to write a program to calculate simple interest; as follows:

  • Get input principle amount and store in some variable.
  • Get input time and store in some variable..
  • Get input rate and store in some variable..
  • To calculate simple interest using formula SI = (principle * time * rate) / 100.
  • Finally, print the result of simple interest.

C Program to Calculate Simple Interest using Formula

/**
 * 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;
}

The output of the above c program; as follows:

Enter principle (amount): 10000
Enter time: 1.5
Enter rate: 5
Simple Interest = 750.000000

C Program to Calculate Simple Interest using Function

/**
 * C program to calculate simple interest
 */

#include <stdio.h>

// function for finding simple interest
float SimpleInt(float p, float r, float t)
{
    float si;
    si = (p * r * t)/100; // formula
    return si; // returning yhe value of si
}

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);

    /* Call function with paramters to Calculate simple interest */
     SI = SimpleInt(principle, rate, time);

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

    return 0;
}

The output of the above c program; as follows:

Enter principle (amount): 20000
Enter time: 2
Enter rate: 5
Simple Interest = 2000.000000

Recommended C Programs

AuthorDevendra Dode

Greetings, I'm Devendra Dode, a full-stack developer, entrepreneur, and the proud owner of Tutsmake.com. My passion lies in crafting informative tutorials and offering valuable tips to assist fellow developers on their coding journey. Within my content, I cover a spectrum of technologies, including PHP, Python, JavaScript, jQuery, Laravel, Livewire, CodeIgniter, Node.js, Express.js, Vue.js, Angular.js, React.js, MySQL, MongoDB, REST APIs, Windows, XAMPP, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL, and Bootstrap. Whether you're starting out or looking for advanced examples, I provide step-by-step guides and practical demonstrations to make your learning experience seamless. Let's explore the diverse realms of coding together.

Leave a Reply

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