los valores no se actualizan con los años
Publicado por hocine (1 intervención) el 03/06/2021 20:17:15
hola, he realizado un program en c, el cual imprime el año y el rédito según los intereses, mi problema es que los valores no se actualizan con los años, alguien podría ayudarme?
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
#include <stdio.h>
float interest(float balance, float rate);
int main(void) {
float yields[4];
int header[] = {3, 4, 6, 9};
int years;
float balance = 400;
printf("Insert the number of years\n");
scanf("%d", &years);
for (int i = 0; i < 4; i++){
if(i == 0){printf("year ");}
printf(" %i%% ", header[i]);}
for (int k = 1; k <= years; k++) {
printf("\n n%i ",k);
for (int j = 0; j < 4; j++) {
yields[j] = interest(balance,header[j]);
printf(" %.2f ", yields[j]);
}
}
}
float interest(float balance, float rate){
balance += balance * rate / 100;
return balance;
}
Valora esta pregunta
0