/* Program to calculate the compound interest and amount using fn subprogram */ /* Problem 27 */ #include #include #include float CmpdInt(float pr, float ra, float ti) { float cmpd_int; cmpd_int = (pr * pow((1 + ra),ti)) - pr; return cmpd_int; } main() { float p,r,t; float ci; float amount; clrscr(); printf("Please enter the principal : "); scanf("%f",&p); printf("Now enter the rate of interest : "); scanf("%f",&r); printf("Also enter the time period (in years) : "); scanf("%f",&t); ci = CmpdInt(p,r,t); amount = ci + p; printf("\nThe compound interest = Rs. %.2f and amount = Rs. %.2f",ci,amount); printf("\n\nPress any key to exit..."); getch(); }