An interactive C program to calculate INCOME TAX

By | August 5, 2013

First we need to know the INCOME TAX SLAB 2013 or whichever you prefer before calculating INCOME TAX for the person.
The INCOME TAX SLAB 2013 is as follows:-
First     Rupees         2, 00,000/- of income      :    0% tax
Next     Rupees         5, 00,000/- of income      :    10% tax
Next     Rupees         10, 00,000/- of income    :    20% tax
An Amount Rupee     above 10, 00,000/-         :    30% tax

Now, find out the variables needed for this program calculating INCOME TAX.

Here we find out two variables for this program. First is     INCOME of the person which is to be entered by the user. Second is the TAX to be calculated by the program to be payable by the person.

we have INCOME ,TAX. (i.e. Two Variables)

Now decide the data type for the variables INCOME ,TAX.
Whenever we are using anything related to money, we should use float or double .float can hold smaller values compared to double. Hence we will omit float. Select double as our data type.

double INCOME,TAX;
Variables and data type selection done.

Interactive means the program will not have any hard coded values assigned to variables but user has to provide them.

To get values from the user screen we have a function called scanf() which will help us to scan values entered by the user by keyboard and visible on the screen.
We cannot expect that user should enter values in the sequence blindly without knowing what to enter. For that purpose we should guide the user to enter expected values by displaying message.

(E.g.  ENTER THE INCOME OF A PERSON : ) than scan the value entered for Income in INCOME and so on.

printf("THE INCOME TAX PAYABLE OF A PERSON IS : %.2lf",TAX);
Here we are using %.2lf instead of %f so that the Amount is printed to Two Decimal Digits.

Note: – Remember whenever you are scanning or printing the values of double be careful to  write %lf instead of just %f. Because %lf is used for double data type and %f is used for float data type.

program code:-

#include<stdio.h>
void main()
{
double INCOME,TAX;
clrscr();
printf("ENTER THE INCOME OF A PERSON : ");
scanf("%lf",&INCOME);
if(INCOME<=200000)
{
TAX=0;
}
else if(INCOME>200000 && INCOME<=500000)
{
TAX=(INCOME-200000)/10;
}
else if(INCOME>500000 && INCOME<=1000000)
{
TAX=(((INCOME-500000)/10)*2)+30000;
}
else if(INCOME>1000000)
{
TAX=(((INCOME-1000000)/10)*3)+130000;
}
printf("THE INCOME TAX PAYABLE OF A PERSON IS : %.2lf",TAX);
getch();
}

Output:-

C_program_income_tax

C_program_income_tax_output

Leave a Reply