C Online Compiler
Example: Compound Interest Program in C using While loop
C
C++
C#
Java
Python
PHP
main.c
STDIN
Run
// Compound Interest Program in C using While loop #include <stdio.h> int main() { float p, t, r, CI = 0.00; // p - To store the principle amount // t - To store the time amount // r - To store the rate amount // CI - To store the compound interest value printf("Enter the principal (Amount), Time, and Rate::\n"); scanf("%f%f%f", &p, &t, &r); // Calculate compound interest double TimePow = 1.00; int i = 0; while (i < t) { TimePow *= (1 + r / 100); if (i == (t - 1)) CI = p * TimePow; i++; } // It will return the final Output printf("\nCompound Interest = %f\n", CI); return 0; }
56 55 34
Output
Clear
ADVERTISEMENTS