C program to calculate simple interest

Here's a simple C program to calculate simple interest:

#include <stdio.h> int main() { // Declare variables float principal, rate, time, simpleInterest; // Input principal amount, rate of interest, and time period printf("Enter principal amount: "); scanf("%f", &principal); printf("Enter rate of interest: "); scanf("%f", &rate); printf("Enter time period (in years): "); scanf("%f", &time); // Calculate simple interest simpleInterest = (principal * rate * time) / 100; // Display the result printf("Simple Interest = %.2f\n", simpleInterest); return 0; }

This program takes user input for the principal amount, rate of interest, and time period. It then calculates the simple interest using the formula: Simple Interest = (principal * rate * time) / 100. Finally, it displays the calculated simple interest.

Here's an example of what the output might look like when you run the program and input values:

Enter principal amount: 1000 Enter rate of interest: 5.5 Enter time period (in years): 2 Simple Interest = 110.00

In this example, the user entered a principal amount of 1000, a rate of interest of 5.5%, and a time period of 2 years. The program then calculated the simple interest using the formula and displayed the result, which is 110.00.

Prasun Barua

Prasun Barua is an Engineer (Electrical & Electronic) and Member of the European Energy Centre (EEC). His first published book Green Planet is all about green technologies and science. His other published books are Solar PV System Design and Technology, Electricity from Renewable Energy, Tech Know Solar PV System, C Coding Practice, AI and Robotics Overview, Robotics and Artificial Intelligence, Know How Solar PV System, Know The Product, Solar PV Technology Overview, Home Appliances Overview, Tech Know Solar PV System, C Programming Practice, etc. These books are available at Google Books, Google Play, Amazon and other platforms.

*

Post a Comment (0)
Previous Post Next Post