C program to calculate Simple Interest

Write a C program to input principle (amount), time and rate (P, T, R) from user and find Simple Interest. How to calculate simple interest in C programming if principle, time and rate are given by user. C program for Simple Interest.

Example:
Input principle: 1200
Input time: 2
Input rate: 5.4
Output Simple Interest = 129.600006

Required knowledge

Fundamentals of C, Data types, Talking user input in C

Simple Interest

Simple Interest can be given by the formula:
Principle * Time * Rate / 100

Program

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

#include <stdio.h>

int main()
{
    float amount, time, rate, SI;

    // Read principle, rate and time from user
    printf("Enter principle (amount): ");
    scanf("%f", &amount);
    printf("Enter time: ");
    scanf("%f", &time);
    printf("Enter rate: ");
    scanf("%f", &rate);

    // Calculates simple interest
    SI = (amount * time * rate) / 100;

    printf("\nSimple Interest = %f", SI);

    return 0;
} 


Output
X
_
Enter principle (amount): 1200
Enter time: 2
Enter rate: 5.4
Simple Interest = 129.600006

Happy coding ;)


Any doubt or suggestion write here. I will try my best to help. Before posting your code you must escape it to view. To format your source code and use format highlighting, post your source code inside
< code >< pre > -- Your source code -- < /pre >< /code > (Remove spaces from pre and code tags).

1 comment:

  1. The moon’s gravity is about 17 percent of Earth’s. Write a program that allows you to enter your weight and computes your effective weight on the moon.

    ReplyDelete