Basic C Program to find Net Salary

     In this C program we will see how to find the Net Salary of an employee using the formula: 

Net Salary = Gross salary - PF . Here, Gross Salary = Basic Salary + DA(25% of basic salary) + HRA(15% of basic salary) ; PF = 10% of Gross Salary.

C Program To Find Net Salary
  •  LOGIC: 

First we'll find DA and HRA from basic salary given by user. Then we'll calculate Gross salary and PF.

And finally we'll calculate Net Salary of the employee.

 

  • ALGORITHM:
  1. Start
  2. Input Basic salary from user
  3. Calculate DA = (25 x Basic Salary) / 100
  4. Calculate HRA = (15 x Basic Salary) / 100
  5. Calculate Gross Salary = Basic salary + DA + HRA
  6. Calculate PF = (10 x Gross Salary) / 100
  7. Calculate Net Salary = Gross Salary - PF
  8. Print Net Salary
  9. End
  • CODE:

 

#include <stdio.h>

int main ()
{
    //declare the variables
    float BSDAHRAGSPFNET_SAL;
    printf("Enter Basic Salary : $ ");
    //input basic salary from user
    scanf("%f",&BS);

    //calculate DA
    DA=(25*BS)/100;
    //calculate HRA
    HRA=(15*BS)/100;
    //calculate Gross salary
    GS=BS+DA+HRA;
    //calculate PF
    PF=(10*GS)/100;
    //calculate Net Salary
    NET_SAL=GS-PF;
    
    //print NET SALARY
    printf("Net Salary of the Employee is : $ %.2f",NET_SAL);

    return 0;
}

 

  • OUTPUT:

Enter Basic Salary : $ 20000
Net Salary of the Employee is : $ 25200.00

 

  • CHALLENGE.2:

 Try to make a C program to calculate simple interest on any amount. 


That's it for today. If you have any problem then don't hesitate to comment.

Share, Subscribe and keep coding...

Comments