1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
| // calculating the yearly interests
#include <stdio.h>
/* -ed- inutile et non standard.
#include <conio.h>
*/
#include <stdlib.h>
#include <math.h>
/* -ed-
void main (void)
main () returne int. Toujours.
*/
int main (void)
{
int
/* -ed- non utilisee
counter = 0,
*/
/* -ed- variable non initialisee. ajoute '= 0' */
years = 0;
/* -ed-
float b = 0.07;
je recommande de faire les calculs en double
Tout ce qui dépend de b devrait etre de type double...
*/
double b = 0.07;
long yearly_amount, money, yearly_value, changing_value = 0;
printf ("please enter the value .. \n");
/* -ed-
scanf ("%dl", &money);
pour long, c'est "%ld" et non "%dl"
*/
scanf ("%ld", &money);
yearly_amount = money * b;
/* -ed-
printf ("the value of cumulated yearly interest is %dl", yearly_amount);
meme probleme...
ajoute \n
*/
printf ("the value of cumulated yearly interest is %ld\n", yearly_amount);
yearly_value = money + yearly_amount;
while (changing_value % 3 == 0)
{
yearly_amount = yearly_value * b;
changing_value = yearly_amount + changing_value;
years++;
}
/* -ed- ajoute \n */
printf ("the needed year to gain 3 times the earned money are %d\n", years);
/* -ed- inutile et non standard.
getch ();
*/
/* -ed- parce que main() retourne int... */
return 0;
} |
Partager