 write a program that receive a salary and calculate its tax this means that if it is to 500 print free tax and if it is between 500 to 1000 it belongs to 1 percentage tax and if it is between 1000to 1500 it belongs 2% tax and if it is between 1500 to 2000 it belongs 3% tax and if it is over 2000 it belongs 4% tax.
tnx please write this program to c.

Meanwhile you are in hurry,so here you go !!

``````#include <stdio.h>

int main(void) {
int salary;
int tax=0;
scanf("%d",&salary);
if(salary<500)
printf("free tax\n");
else if(salary>=500&&salary<1000)
{
tax=0.01*salary;
printf("%g",tax);

}
else if(salary>=1000&&salary<1500)
{
tax=0.02*salary;
printf("%g",tax);

}
else if(salary>=1500&&salary<2000)
{
tax=0.03*salary;
printf("%g",tax);

}
else
{
tax=0.04*salary;
printf("%g",tax);
}
return 0;
}``````
1 Like

#include<stdio.h>
int main()
{
double payable;
if(tax<=500)
printf(“freetax”);
else
{
if(tax>500 && tax<=1000)
payable=0.01tax;
else if(tax>1000 && tax<=1500)
payable=0.0.2
tax;
else if(tax>=1500 && tax<=2000)
payable=0.03tax;
else
payable=0.04
tax;
printf("%lf",payable);
}
}

2 Likes

thanks.but I 'm not professional.can you rewrite it simple and explain about it,please.

really thank you so much.

its a simple if else problem.among the given if else conditions only one is executed.read the tutorials about if else basics.

yes,I understand it.thanks