For deletes my following order

Hello, i have a problem with my code, when i want to calculate the "pagoInteres" it equals it to 0 and i need to calculate the "interes" trough the formula but i keep getting a 0 as a result no matter where i put the formula (inside if or for) , i have been trying for hours and i can't figure it out why

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
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#define interes .20


int main()
{
	int i=0, j=0;
	float year=0, saldoInicial=0, pagoInteres, pagoCapital=0, pagoAnual=0, saldoFinal=0, tabla[20][20];
	printf("Introduce el costo del automovil:  ");
	scanf("%f", &saldoInicial);
	
	printf("Introduce el numero de anos a pagar:  ");
	scanf("%f", &year);
	
	pagoCapital = saldoInicial/year;
	
	for(i=0;i<5;i++)
	{
		for(j=0;j<year;j++)
		{
 			pagoAnual = pagoCapital+ pagoInteres;
			saldoFinal = saldoInicial - pagoCapital;
			pagoInteres = saldoInicial*interes;
			 if(i==0)
			 {
				 printf("ano    %d	", j+1);
				 printf("%d    %d\n", i,j);
			 }
			
			if(i==1)
 			{
				printf("saldo inicial: %.2f ", saldoInicial);
				printf("%d		%d\n", i, j);
 				saldoInicial = saldoInicial - pagoCapital;
			 }
			
			if(i==2)
			{
				printf("Pago interes  %.2f	", pagoInteres);
				printf("%d    %d\n", i,j);
			}
			if(i==3)
			{
				printf("pagoCapital  %.2f	", pagoCapital);
				printf("%d    %d\n", i,j);
			}
			if(i==4)
			{
				printf("pagoAnual  %.2f	", pagoAnual);
				printf("%d    %d\n", i,j);
			}
			if(i==5)
			{
				printf("saldoFinal  %.2f	", saldoFinal);
				printf("%d    %d\n", i,j);
			}
		

		}
	}
}
Try
#define interes .20f
If it still doesn't work try to change from scanf to scanf_s
1
2
3
4
	scanf_s("%f", &saldoInicial);
	
	printf("Introduce el numero de anos a pagar:  ");
	scanf_s("%f", &year);
Last edited on
Topic archived. No new replies allowed.