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
|
// calculating the yearly interests
# include <stdio.h>
# include <conio.h>
# include <stdlib.h>
# include <math.h>
void main (void)
{
int counter=0, years;
float b=0.07;
long yearly_amount, money, yearly_value, changing_value=0;
printf("please enter the value .. \n");
scanf("%dl", &money);
yearly_amount=money*b;
printf("the value of cumulated yearly interest is %dl", yearly_amount);
yearly_value=money+yearly_amount;
while (changing_value%3==0)
{
yearly_amount=yearly_value*b;
changing_value=yearly_amount+changing_value;
years++;
}
printf("the needed year to gain 3 times the earned money are %d", years);
getch();
} |
Partager