C Online Compiler
Example: Compound Interest Program in C using Function
C
C++
C#
Java
Python
PHP
main.c
STDIN
Run
// Compound Interest Program in C using Function #include <stdio.h> #include <math.h> // This function will return the compound interest float CalcCompound(float p, float t, float r) { // Calculate the compound interest return p * (pow((1 + r / 100), t)); } // It's the driver function int main() { float p, t, r, CI; // p - To store the principle amount // t - To store the time amount // r - To store the rate amount printf("Enter the principal (Amount), Time, and Rate::\n"); scanf("%f%f%f", &p, &t, &r); // It will return the final Output printf("\nCompound Interest = %f\n", CalcCompound(p, t, r)); return 0; }
54 34 67
Output
Clear
ADVERTISEMENTS