C Online Compiler
Example: C Program to Calculate Simple Interest using do-while loop
C
C++
C#
Java
Python
PHP
main.c
STDIN
Run
// C Program to Calculate Simple Interest using do-while loop #include <stdio.h> int main() { float x = 1, y, SI; // `SI` = value of the simple interest printf("Enter the principal (amount), time, and rate::\n"); int count = 1; do { scanf("%f", &y); // It will calculate the value of simple interest x *= y; if (count == 3) SI = x/100; count++; } while (count <= 3); // It will produce the final output printf("\nSimple Interest = %.2f\n", SI); return 0; }
23 45 76
Output
Clear
ADVERTISEMENTS