Lab Manual PPS

How to calculate Net salary? | PPS Lab Manual: Program no 2 | Provident Fund | Net Salary

Basic salary of an employee is input through the keyboard. The DA is 25% of the basic
salary while the HRA is 15% of the basic salary. Provident Fund is deducted at the rate of 10% of
the gross salary (BS+DA+HRA). Program to calculate the Net Salary.

Code

#include <stdio.h>

int main()
{
    float BS, DA, HRA, GS, PF, NS;
    printf("Enter Your Basic Salary:");
    scanf("%f", &BS);
    DA = 0.25*BS;
    HRA = 0.15*BS;
    GS = (BS+DA+HRA);
    PF = 0.10*GS;
    NS = GS-PF;
    printf("DA : %f\nHRA : %f\nGS : %f\nPF : %f\n", DA,HRA,GS,PF);
    printf("Your Net Salary is %f", NS);

    return 0;
}

Description

Calculating the net salary of an employee is a common task in many programming applications. In this blog post, we will discuss how to write a program in C language to calculate the net salary of an employee given the basic salary, DA, and HRA.

The problem statement says that the DA is 25% of the basic salary while the HRA is 15% of the basic salary. Provident Fund is deducted at the rate of 10% of the gross salary (BS+DA+HRA). The net salary can be calculated as the difference between the gross salary and the Provident Fund deduction.

Now that we understand the problem statement, let’s understand the program mentioned above.

In this program, we first declare the necessary variables for the basic salary, DA, HRA, gross salary, Provident Fund, and net salary. We prompt the user to enter the basic salary using the printf and scanf functions. We then calculate the DA, HRA, gross salary, Provident Fund, and net salary using the given formulas. Finally, we print the results using the printf function.

Let’s test the program with an example. Suppose we have an employee with a basic salary of Rs. 5000. We can run the program and input this value.

Output

Enter Your Basic Salary:5000
DA:1250.000000
HRA:750.000000
GS:7000.000000
PF:700.000000
Your Net Salary is 6300.000000.

This result matches the calculation based on the given formulas. The DA is 25% of the basic salary, which is Rs. 1250. The HRA is 15% of the basic salary, which is Rs. 750. The gross salary is the sum of the basic salary, DA, and HRA, which is Rs. 7000. The Provident Fund is 10% of the gross salary, which is Rs. 700. Finally, the net salary is the difference between the gross salary and Provident Fund, which is Rs. 6300.

In conclusion, we have seen how to write a program in C language to calculate the net salary of an employee given the basic salary, DA, and HRA. This program can be used in many applications where the net salary of an employee needs to be calculated.

For more detailed explanation, watch video below.