21. Write a program in C to calculate the income tax based on the salary using if else statements.
Purpose:
The purpose of the program is to calculate the income tax based on the salary of an individual. By using 'if-else' statements, the program can determine the tax rate applicable to different income brackets and calculate the tax amount accordingly. This helps individuals understand how much tax they need to pay based on their income level.
Agenda:
1. Define variables to store the salary and tax amount.
2. Prompt the user to input their salary.
3. Use 'if-else' statements to determine the tax rate based on different income brackets.
4. Calculate the tax amount based on the salary and applicable tax rate.
5. Display the calculated tax amount to the user as the output.
Real-life applications:
In real-life scenarios, this program can be used by individuals, tax professionals, or financial advisors to calculate income tax for individuals or households. It can assist in financial planning, budgeting, and ensuring compliance with tax regulations. Employers can also use similar programs to calculate and deduct income tax from employees' salaries accurately.
A program in C Language to calculate the income tax based on the salary using if else statements.
/* C language program to calculate the income tax based on the salary using if else statements.*/
#include <stdio.h>
int main()
{
float salary, tax = 0;
printf("Enter your annual salary: ");
scanf("%f", &salary);
if (salary <= 250000)
{
tax = 0;
}
else if (salary > 250000 && salary <= 500000)
{
tax = (salary - 250000) * 0.05;
}
else if (salary > 500000 && salary <= 1000000)
{
tax = 12500 + (salary - 500000) * 0.1;
}
else {
tax = 62500 + (salary - 1000000) * 0.15;
}
printf("Income tax to be paid: %.2f", tax);
return 0;
}
Output
Enter a character:
10
10 is a digit.
Explanation
The program starts by declaring variables for salary and tax.
It prompts the user to enter their annual salary.
Using if-else statements, the program calculates the income tax based on the salary entered by the user.
If the salary is less than or equal to 250,000, the tax is set to 0.
If the salary is between 250,001 and 500,000, the tax is calculated at a rate of 5% on the amount exceeding 250,000.
If the salary is between 500,001 and 1,000,000, the tax is calculated at a rate of 10% on the amount exceeding 500,000 plus a fixed amount of 12,500.
If the salary is above 1,000,000, the tax is calculated at a rate of 15% on the amount exceeding 1,000,000 plus a fixed amount of 62,500.
The program then prints the income tax to be paid based on the salary entered by the user.
Previous :-->> 20. C language program to check if a given character is a special character of digit using if else statement.
NEXT:
Loops Assignments in C
-->>ALL Conditionl statements Programs