Last active
August 29, 2015 14:02
-
-
Save mr-fool/6820a68ce139455bc33b to your computer and use it in GitHub Desktop.
A program that normalize fractions and simplify it
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /*Calculating compound interest*/ | |
| #include <stdio.h> | |
| #include <math.h> | |
| int main (void) { | |
| double amount; | |
| double principal; | |
| double rate; | |
| int year; | |
| int i; | |
| printf("Please enter the principal, rate, year\n"); | |
| scanf("%lf %lf %d",&principal,&rate,&year); | |
| /*Printing the header*/ | |
| printf("%4s%21s\n", "Year","Amount on deposit"); | |
| /*Calculate the amount on deposit for x year*/ | |
| for ( i = 0 ; i <= year; i++) { | |
| /*Calculate new amount for specified year*/ | |
| amount = principal * pow (1.0 + rate, year); | |
| /*Output one table row*/ | |
| printf("%4d%21.2lf\n",i,amount); | |
| } | |
| return 0; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| allFiles: fraction.c | |
| gcc -Wall fraction.c -o fraction.out -lm | |
| clean: | |
| rm *.o fraction.out |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment