An employee's gross salary includes his basic salary and additional benefits such as House Rent Allowance (HRA) and Dearness Allowance (DA). This tutorial guides you in writing a C program to calculate an employee's gross salary considering his Basic Pay, HRA, and DA.
What are House Rent Allowance (HRA) and Dearness Allowance (DA)?
HRA is a component of salary that the employer provides to the employees as compensation for their house rent. On the other hand, DA is the cost of living adjustment allowance given to employees in India to reduce the effect of inflation.
C Program to Calculate Gross Salary with HRA and DA
Here is a simple C program to calculate the gross salary of an employee:
#include<stdio.h>
int main() {
float basic_salary, gross_salary, HRA, DA;
printf("Enter the basic salary: ");
scanf("%f", &basic_salary);
if(basic_salary <= 10000) {
HRA = basic_salary * 0.2;
DA = basic_salary * 0.8;
} else if(basic_salary <= 20000) {
HRA = basic_salary * 0.25;
DA = basic_salary * 0.9;
} else {
HRA = basic_salary * 0.3;
DA = basic_salary * 0.95;
}
gross_salary = basic_salary + HRA + DA;
printf("Gross Salary is: %.2f\n", gross_salary);
return 0;
}
In the above program, we first prompt the user to input the basic salary. The program calculates the HRA and DA using different percentages based on the basic salary entered:
- For a basic salary less than or equal to 10,000, HRA is 20%, and DA is 80% of the basic salary.
- For a basic salary of up to 20,000, HRA is 25%, and DA is 90% of the basic salary.
- For a basic salary of more than 20,000, HRA is 30%, and DA is 95% of the basic salary.
Finally, the gross salary is calculated by adding the basic salary, HRA, and DA.
Program Output:
Enter the basic salary: 15000
Gross Salary is: 32250.00
In the above case, the basic salary is Rs.15,000. In the program, HRA is 25% of the Basic Salary (3,750), and DA is 90% of the Basic Salary (13,500). Adding these amounts to the basic salary, we get a gross salary of Rs.32,250.
Dearness Allowance (DA) is subject to change over time and may vary depending on government regulations, cost of living, inflation rate, and other factors.
This is a basic implementation and does not consider other possible components of a salary. Feel free to modify and extend it as per your needs.