How to write a c program to calculate interest in C Programming ?
Solution:
#include <stdio.h>
int main()
{
int principal, rate, year, i;
double amount;
printf("Enter principal amount: ");
scanf("%d", &principal);
printf("Enter rate of interest: ");
scanf("%d", &rate);
printf("Enter number of years: ");
scanf("%d", &year);
printf("\nYear\tAmount\n\n");
amount = principal;
for(i = 1; i <= year; i++)
{
amount += principal * rate / 100.0;
printf("%d\t%lf\n", i, amount);
}
return 0;
}