If Basic Salary <= 10000 then HRA = 20% and DA = 70%.
If Basic Salary is between 10001 to 20000 then HRA = 25% and DA = 80%.
If Basic Salary > 20000 then HRA = 30% and DA = 90%.
How to calculate gross salary of an employee using C program.
Example:
Input :
Input basic salary of an employee : 24000
Output:
Gross Salary = 52800
Input basic salary of an employee : 24000
Output:
Gross Salary = 52800
Formula to calculate gross salary of an employee.
A gross salary is a final salary after the addition of DA, HRA and other allowances. Hare DA is Dearness Allowance and HRA is House Rent Allowance.The formula of DA, HRA and gross salary is.
da = basic_salary * (DA/100)
If DA = 70% then da = basic_salary * (70/100). Which can be written as da = basic_salary * 0.7 .
hra = basic_salary * (20/100)
If HRA = 20% then da = basic_salary * (70/100). Which can be written as hra = basic_salary * 0.2 .
gross_salary = basic_salary + hra +da.
Algorithm to Calculate Gross Salary:
Step 1: Start
Step 2: Read basic salary of an employee
Step 3: Check if basic_salary <= 10000 then hra = basic_salary * 0.2 and da = basic_salary * 0.8.
Step 4: Similarly check other condition and compute hra and da.
Step 5: Calculate gross salary by using formula gross_salary = basic_salary + hra + da.
Step 6: Print gross salary.
Step 7: End
Step 2: Read basic salary of an employee
Step 3: Check if basic_salary <= 10000 then hra = basic_salary * 0.2 and da = basic_salary * 0.8.
Step 4: Similarly check other condition and compute hra and da.
Step 5: Calculate gross salary by using formula gross_salary = basic_salary + hra + da.
Step 6: Print gross salary.
Step 7: End
FlowChart to Calculate Gross salary:
Here we learn, how to calculate simple interest by using C language./* C Program to Calculate Gross Salary of an Employee */
#include <stdio.h>
int main()
{
float basic_salary, hra, da, gross_salary;
clrscr();
// Input basic salary of an employee
printf("\n Enter the Basic Salary of an Employee : ");
scanf("%f", &basic_salary);
// Calculate DA and HRA according to specified condition
if (basic_salary <= 10000)
{
hra = basic_salary * 20 / 100; // or hra = basic_salary * 0.2
da = basic_salary * 70 / 100; // or da= basic_salary * 0.7
}
else if (basic_salary <= 20000)
{
hra = basic_salary * 0.25;
da = basic_salary * 0.8;
}
else
{
hra = basic_salary * 0.3;
da = basic_salary * 0.9;
}
// Calculate gross salary
gross_salary = basic_salary + hra + da;
// Print the gross salary
printf("\n The gross salary = %.2f", gross_salary);
return 0;
}
Note: Here %.2f is used to print the gross salary only up to two decimal places because of money format.
Normally %f is use to print fractional values up to six decimal places.
OUTPUT:
Enter the Basic Salary of an Employee : 24000
The gross salary = 52800.00
The gross salary = 52800.00
No comments:
Post a Comment