C program for employee salary calculation
In this post, you will learn how to calculate the employee salary using the C programming language.
The salary calculator is really useful and vital for calculating and knowing the development status of the representative and appraising the increments and deductions that are being made by the employer on one's employee salary.
The salary comprises of different parts, and there is a difference between the gross salary received and the net salary received.
Example1: C program for employee salary calculation
Suppose, we have given the HRA and DA percentages.
- If the Basic Salary is less than or equal to 15000, then HRA = 10% of the basic, and DA = 12% of the basic.
- Basic Salary is less than or equal to 20000, then HRA = 15% and DA = 20%.
- Basic Salary is greater than 20000, then HRA = 20% and DA = 30%.
In the given C program, we asked the user to enter the basic salary of an employee and then calculate the total salary.
/* C Program to Calculate Gross Salary of an Employee */
#include <stdio.h>
int main()
{
float basic_salary, HRA, DA, gross_salary;
printf("\n Enter the Basic Salary of an Employee= ");
scanf("%f", &basic_salary);
if (basic_salary <= 15000)
{
HRA = (basic_salary * 10) / 100;
DA = (basic_salary * 12) / 100;
}
else if (basic_salary <= 20000)
{
HRA = (basic_salary * 15) / 100;
DA = (basic_salary * 20) / 100;
}
else
{
HRA = (basic_salary * 20) / 100;
DA = (basic_salary * 30) / 100;
}
gross_salary = basic_salary + HRA + DA;
printf("\n Gross Salary of this Employee = %.2f", gross_salary);
return 0;
}
Output of the above code:
Enter the Basic Salary of an Employee= 18000
Gross Salary of this Employee = 24300.00
Example2: C program for employee salary calculation
In the given C program, we ask the user to enter the basic salary, HRA percentage, and DA percentage, and then, using the entered values, we calculate the gross salary of an employee.
/* C Program to Calculate Gross Salary of an Employee */
#include <stdio.h>
int main()
{
char name[60];
float basic_salary, hra_per, da_per, HRA, DA, Gross_Salary;
printf("Enter the Basic Salary of an Employee: ");
scanf("%f", &basic_salary);
printf("Enter the HRA Percentage of an Employee: ");
scanf("%f", &hra_per);
printf("Enter the DA Percentage of an Employee: ");
scanf("%f", &da_per);
HRA = basic_salary * (hra_per /100);
DA = basic_salary * (da_per / 100);
Gross_Salary = basic_salary + HRA + DA;
printf("\nBasic Salary = %.2f \nHRA Amount = %.2f \nDA Amount = %.2f \nGross Salary = %.2f", basic_salary, HRA, DA, Gross_Salary);
return 0;
}
Output of the above code:
Enter the Basic Salary of an Employee: 22000
Enter the HRA Percentage of an Employee: 20
Enter the DA Percentage of an Employee: 30
Basic Salary = 22000.00
HRA Amount = 4400.00
DA Amount = 6600.00
Gross Salary = 33000.00
Related Articles
Prime factors of a number in cArmstrong number program in c
Write a program to check leap year in c
C program to find area of rectangle
C program to convert celsius to fahrenheit
Fibonacci series program in C using recursion
Write a program to find area of circle in C
C program to find greatest of three numbers
C program for addition of two numbers
C program to calculate compound interest
C program to find the ASCII value of a character
C program to convert Decimal to Octal
C program to convert decimal to binary
Write a C program to calculate Simple Interest
C program to check whether a number is even or odd
C program to reverse a number
C program to check palindrome number
C program to check whether an alphabet is a vowel or consonant
Program to find square root of a number in C
C program to check whether a number is positive or negative