C program to calculate the gross salary of an employee; Through this tutorial, we will learn how to calculate the gross salary of an employee.
Program 1 – C Program to Calculate Gross Salary of an Employee
/* C Program to Calculate Gross Salary of an Employee */ #include <stdio.h> int main() { float Basic, HRA, DA, Gross_Salary; printf("\n Please Enter the Basic Salary of an Employee : "); scanf("%f", &Basic); if (Basic <= 10000) { HRA = (Basic * 8) / 100; // or HRA = Basic * (8 / 100) DA = (Basic * 10) / 100; // Or Da= Basic * 0.1 } else if (Basic <= 20000) { HRA = (Basic * 16) / 100; DA = (Basic * 20) / 100; } else { HRA = (Basic * 24) / 100; DA = (Basic * 30) / 100; } Gross_Salary = Basic + HRA + DA; printf("\n Gross Salary of this Employee = %.2f", Gross_Salary); return 0; }
The output of the above c program; as follows:
Please Enter the Basic Salary of an Employee : 25000 Gross Salary of this Employee = 38500.00
Program 2 – C Program to Calculate Gross Salary of an Employee
/* C Program to Calculate Gross Salary of an Employee */ #include <stdio.h> int main() { char name[60]; float Basic, HRA_Per, DA_Per, HRA, DA, Gross_Salary; printf("\n Please Enter the Employee Name : "); gets(name); printf(" Please Enter the Basic Salary of an Employee : "); scanf("%f", &Basic); printf(" Please Enter the HRA Percentage of an Employee : "); scanf("%f", &HRA_Per); printf(" Please Enter the DA Percentage of an Employee : "); scanf("%f", &DA_Per); HRA = Basic * (HRA_Per /100); DA = Basic * (DA_Per / 100); Gross_Salary = Basic + HRA + DA; printf("\n Name = %s \n Basic Salary = %.2f \n HRA Amount = %.2f \n DA Amount = %.2f \n Gross Salary = %.2f", name, Basic, HRA, DA, Gross_Salary); return 0; }
The output of the above c program; as follows:
Please Enter the Employee Name : tutsmake Please Enter the Basic Salary of an Employee : 20000 Please Enter the HRA Percentage of an Employee : 2 Please Enter the DA Percentage of an Employee : 5 Name = tutsmake Basic Salary = 20000.00 HRA Amount = 400.00 DA Amount = 1000.00 Gross Salary = 21400.00