/* Dennis Alcock, 1992, "Illustrating C", Cambridge University Press, Cambridge p. 3 */ #include #include int main(void) /* main program starts */ { /*type statements */ float p, rpct, r, m; int n; /*types in c are printf("\nEnter Principle Rate% No. of years \n"); scanf("%f %f %i", &p, &rpct, &n); /*scanf assumes input is separated by spaces */ r = rpct/100; m = p*r*pow(1+r,n) / (12*(pow(1+r,n)-1)); printf("\nPriciple £%1.2f@%4.2f%% costs £%1.2f per month over %i years",p,rpct,m,n); printf("\nPayments will total £%1.2f\n",12*m*n); return 0; } /* to compile this program :- gcc alcockex1.c -lm -lm makes the math.h available libm.a is in /usr/lib -lfile in the a linker option to load the file libfile.a */