๐Ÿ’ป
B.TECH I YEAR โ€ข I SEMESTER โ€ข R25

Programming for Problem Solving - Lab Manual

C Programming Laboratory โ€ข Program Solution

๐Ÿ“˜ R25 Regulation ๐ŸŽ“ I Year ๐Ÿ“š I Semester ๐Ÿ’ป C Programming ๐Ÿงช Lab Program
Selected Program

Write the program for the simple, compound interest.

โ† All Lab Programs

Write the program for the simple, compound interest.

Algorithm

start
	step1: Read p, rate, time
	step2: SI := (p * rate * time)/100
	step3: CI := p * (1+(rate/100))time - p
	step4: Print SI, CI
stop

Flowchart
flowchart for simple, compound interest in c

C Programming
/* calculate the simple interest and compound interest by reading principal amount, rate of interest and time

The formula to find simple interest is simpleInterest = (principal * rate * time) / 100.

The formula to find compound interest is compoundInterest = principal * pow(1 + (rate / 100), time) - principal. */

#include <stdio.h>
#include <math.h>

int main() {
    float P, rate, time, SI, CI;

    // Input P amount, rate of interest and time
    printf("Enter P,R,T: ");
    scanf("%f%f%f", &P,&rate,&time);
    

    // Calculate simple interest
    SI = (P * rate * time) / 100;

    // Calculate compound interest
    CI = P * pow(1 + (rate / 100), time) - P;

    // Display results
    printf("SI= %f\n", SI);
    printf("CI= %f\n", CI);

    return 0;
}

OUTPUT
Enter P,R,T: 1000 5 10
SI= 500.000000
CI= 628.893860

๐Ÿ’ป Run This C Program

Write the program for the simple, compound interest.
The selected C program is loaded automatically. Edit the code, provide input through STDIN and click Run.

The compiler is embedded using OneCompiler. Your program runs in the embedded C environment; Study Glance does not execute C code directly on your web server.
โ† Back to PPS Lab Programs ๐Ÿ“š All Lab Manuals