From 1b197a92fa82f2f951c438ee4f1c0dfcd88e4cdd Mon Sep 17 00:00:00 2001 From: Geoffrey Frogeye Date: Wed, 20 Jan 2016 11:12:54 +0100 Subject: [PATCH] TD1 E8 --- TP1/E8.c | 34 ++++++++++++++++++++++++++++++++++ TP1/Makefile | 3 +++ 2 files changed, 37 insertions(+) create mode 100644 TP1/E8.c diff --git a/TP1/E8.c b/TP1/E8.c new file mode 100644 index 0000000..f28ff82 --- /dev/null +++ b/TP1/E8.c @@ -0,0 +1,34 @@ +/* Affiche une table de multiplication */ +#include + + +int main() { + + float S0 = 8000; + float t = 0.005; + float x = 250; + + + float S = S0; + int m; + for (m = 1; m <= 12; m++) { + S = S * (1 + t) - x; + printf("Au mois %d, vous devrez %f€ à vôtre banque\n", m, S); + } + + S = S0; + float Sn = S; // Sn : prochaine mensualité + m = 0; + while (Sn > 0) { + m++; + S = Sn; + Sn = S * (1 + t) - x; + } + + m--; // Dans la boucle m prend une mensualité en trop + + printf("Au mois %d, il vous restera %f€ à payer.\n", m, S); + + + return 0; +} diff --git a/TP1/Makefile b/TP1/Makefile index 9ac17f5..c938108 100644 --- a/TP1/Makefile +++ b/TP1/Makefile @@ -27,6 +27,9 @@ E6.exe: E6.c E7.exe: E7.c gcc E7.c -o E7.exe +E8.exe: E8.c + gcc E8.c -o E8.exe + .PHONY: all clean clean: