Previous Next
0 / 20
Module DEMO-32-89DEMO-C-32

Compound Interest

DEMO-C-32 โ€ข Programming in C

Browser-only practice

Problem Statement

Calculate the final amount using the compound interest formula: A = P * pow((1 + r/n), n*t).

Target difficulty: Medium

Constraints

All inputs > 0

Input Format

Four numbers: P (principal), r (rate decimal), n (times per year), t (years).

Output Format

Amount formatted to 2 decimal places.

Sample Testcases

Submit runs every public testcase in this browser. Results and code never leave this device.

Sample #1
Public sample
1000 0.05 12 10
1647.01
1000.0 * (1 + 0.05/12.0)^(12.0*10.0) = 1647.01
Sample #2
Public sample
100 0.02 4 1
102.02
100.0 * (1 + 0.02/4.0)^(4.0*1.0) = 102.02
Sample #3
Public sample
10000 0.01 12 20
12213.01
10000.0 * (1 + 0.01/12.0)^(12.0*20.0) = 12213.01
Sample #4
Public sample
1 1.0 1 1
2.00
1.0 * (1 + 1.0/1.0)^(1.0*1.0) = 2.00

Web terminal

C, C++, Java, and Python run locally in a browser VM. No worker or visualizer is used.

Saved in this browser
Editor settings