#include <stdio.h>
int main() {
int inc;
int ti;
int tf;
int n;
int tax = 0;
int const pd = 3600000;
int const pa= 9000000;
printf("Your income of this year: ");
scanf("%ld", &inc);
printf("\nNumber of dependent: ");
scanf("%d", &n);
tf = 12*(pa + n*pd);
ti = inc - tf;
printf("Tax-free income: %ld", tf);
printf("\nTaxable income: %ld", ti);
if (ti<= 0){
printf("\nIncome tax: 0");
return 0;
}
if (ti > 18000000){
tax = (ti + 18000000) * (20 / 100);
printf("\n %d %d \n", ti, tax);
ti = 18000000;
}
if (ti > 10000001 && ti <=18000000){
tax += (ti - 10000000) * (15 / 100);
printf("%d %d \n", ti, tax);
ti = 10000000;
}
if (ti > 5000001 && ti <=10000000){
tax += (ti - 5000000) * (10 / 100);
printf("%d %d \n", ti, tax);
ti = 5000000;
}
if (ti <= 5000000){
tax += ti * (5 / 100);
printf("%d %d \n", ti, tax);
}
printf("\nIncome tax: %d", tax );
return 0;
}
I can't get the tax variable to add up all the different value in my code. When debugging it keep printing out 0 for the tax variable. Sorry if I missed something important i am new student.