Here is a simple program which finds the Gross and Net pay of an employ when the user enters his basic salary.
Logic : Here we divided the the employee into three categories according to his basic pay. The first category is getting the basic pay less than Rs.5000/-. Second category is having the basic between Rs.5000/- to Rs.10000/-, and the third is getting the basic more than Rs.10000/-. Basic idea here is to calculate the DA and TAX amount according to the category.
Finally it calculates the desired two as,
Gross = Basic + DA+ HRA and,
Net = Gross- ( PF + Tax ).
We can add categories as we want. Also one can change the step values. Hope one can make it clear for himself the algorithm for the program by going through the codes.
float basic, da, hra, tax, pf, gross, net;
printf(“\n\n\t ENTER YOUR NAME…:”);
printf(“\n\t ENTER THE BASIC SALARY…:”);
pf = 0.08 * basic;
if (basic < 5000)
da = 0.3 * basic;
hra = 0.08 * basic;
else if ((basic >= 5000) && (basic < 10000))
da = 0.4 * basic;
hra = 0.1 * basic;
da = 0.5 * basic;
hra = 0.2 * basic;
gross = basic + da + hra;
net = gross – tax + pf;
printf(“\n\n\t THE GROSS SALARY IS…: %f”, gross);
printf(“\n\n\t THE NET SALARY IS…: %f”, net);
Leave a Reply