In this C program we will see how to find the Net Salary of an employee using the formula:
Net Salary = Gross salary - PF . Here, Gross Salary = Basic Salary + DA(25% of basic salary) + HRA(15% of basic salary) ; PF = 10% of Gross Salary.
- LOGIC:
First we'll find DA and HRA from basic salary given by user. Then we'll calculate Gross salary and PF.
And finally we'll calculate Net Salary of the employee.
- ALGORITHM:
- Start
- Input Basic salary from user
- Calculate DA = (25 x Basic Salary) / 100
- Calculate HRA = (15 x Basic Salary) / 100
- Calculate Gross Salary = Basic salary + DA + HRA
- Calculate PF = (10 x Gross Salary) / 100
- Calculate Net Salary = Gross Salary - PF
- Print Net Salary
- End
- CODE:
#include <stdio.h>
int main ()
{
//declare the variables
float BS, DA, HRA, GS, PF, NET_SAL;
printf("Enter Basic Salary : $ ");
//input basic salary from user
scanf("%f",&BS);
//calculate DA
DA=(25*BS)/100;
//calculate HRA
HRA=(15*BS)/100;
//calculate Gross salary
GS=BS+DA+HRA;
//calculate PF
PF=(10*GS)/100;
//calculate Net Salary
NET_SAL=GS-PF;
//print NET SALARY
printf("Net Salary of the Employee is : $ %.2f",NET_SAL);
return 0;
}
- OUTPUT:
Enter Basic Salary : $ 20000
Net Salary of the Employee is : $ 25200.00
- CHALLENGE.2:
Try to make a C program to calculate simple interest on any amount.
That's it for today. If you have any problem then don't hesitate to comment.
Share, Subscribe and keep coding...
Comments
Post a Comment