C Online Compiler
Example: Simple Interest Program in C using For loop
C
C++
C#
Java
Python
PHP
main.c
STDIN
Run
// Simple Interest Program in C using For 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"); for (int count = 1; count <= 3; count++) { scanf("%f", &y); // It will calculate the value of simple interest x *= y; if (count == 3) SI = x/100; } // It will produce the final output printf("\nSimple Interest = %.2f\n", SI); return 0; }
34 6 12
Output
Clear
ADVERTISEMENTS