C Program to Find Simple Interest

«
»

This is a C Program to calculate the simple interest.

Problem Description

This C Program calculates the simple interest.

Problem Solution

This C Program calculates the simple interest given the principal amount, rate of interest and time. The formula to calculate the simple interest is: simple_interest = (p * t * r) / 100 where p is principal amount, t is time & r is rate of interest.

advertisement
Program/Source Code

Here is source code of the C program to calculate the simple interest. The C program is successfully compiled and run on a Linux system. The program output is also shown below.

/*
 * C program to find the simple interest, given principal,
 * rate of interest and time.
 */
#include <stdio.h>
 
void main()
{
    float principal_amt, rate, simple_interest;
    int time;
 
    printf("Enter the values of principal_amt, rate and time \n");
    scanf("%f %f %d", &principal_amt, &rate, &time);
    simple_interest = (principal_amt * rate * time) / 100.0;
    printf("Amount = Rs. %5.2f\n", principal_amt);
    printf("Rate = Rs. %5.2f%\n", rate);
    printf("Time = %d years\n", time);
    printf("Simple interest = %5.2f\n", simple_interest);
}
Program Explanation

This C program, we are reading the value for principal_amt, rate and time using the ‘principal_amt’, ‘rate’ and ‘time’ variables respectively.

advertisement
advertisement

To find the simple interest, the following formula is used.
simple_interest = (principal_amt * time * rate) / 100

Runtime Test Cases
 
$ cc pgm3.c
$ a.out
Enter the values of principal_amt, rate and time
12
10
5
Amount = Rs. 12.00
Rate = Rs. 10.00%
Time = 5 years
Simple interest =  6.00

Sanfoundry Global Education & Learning Series – 1000 C Programs.

Participate in C Programming Certification Contest of the Month Now!
advertisement

Here’s the list of Best Books in C Programming, Data-Structures and Algorithms

If you wish to look at other example programs on Mathematical Functions, go to C Programming Examples on Mathematical Functions. If you wish to look at programming examples on all topics, go to C Programming Examples.

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & technical discussions at Telegram SanfoundryClasses.