w3resource

C Exercises: Compute the simple interest


Calculate simple interest (P, R, T)

Write a C program that accepts the principle, rate of interest, and time and calculates simple interest.

Pictorial Presentation:

C Programming: Compute the simple interest


Sample Solution:

C Code:

#include<stdio.h>
int main() {
    int p, r, t, int_amt;

    // Prompt user to input principle, rate of interest, and time
    printf("Input principle, Rate of interest & time to find simple interest: \n");
    scanf("%d%d%d", &p, &r, &t);

    // Calculate simple interest
    int_amt = (p * r * t) / 100;

    // Display the calculated simple interest
    printf("Simple interest = %d", int_amt);

    return 0;
}

Sample Output:

Input Data: p = 10000, r = 10% , t = 12 year
Input principle, Rate of interest & time to find simple interest: 
Simple interest = 12000

Flowchart:

C Programming Flowchart: Compute the simple interest


For more Practice: Solve these Related Problems:

  • Write a C program to calculate compound interest iteratively and compare it with simple interest.
  • Write a C program to compute simple interest and then determine the total amount payable.
  • Write a C program to calculate simple interest using a user-defined function with input validation.
  • Write a C program to compute both simple and compound interest and display the difference between them.

Go to:


PREV : Find the smallest element in an array and its position.
NEXT : Convert distance from centimeters to inches.

C programming Code Editor:



Have another way to solve this solution? Contribute your code (and comments) through Disqus.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



Follow us on Facebook and Twitter for latest update.