In this tutorial, we are going to see a new program which is c program to calculate gross salary
What is gross salary?
The gross salary is different from the net salary which is calculated as annual basis.
How to calculate gross salary:
Formula: Gross Salary = Basic + DA + HRA
For this basic => basic pay , DA => dearness allowance and HRA => house rent allowance
The logic to calculate gross salary:
For finding a gross salary we need to take input basic pay, HRA and DA from the user. after that, we calculate the sum of all this sum is our gross salary.
- Declare variable
- Take a user input Basic, HRA, and DA.
- Do sum of all and store in a variable.
- Print sum as gross salary.
C Program to Calculate Gross Salary
int main ()
int basic,hra, da;
printf ("\n Enter basic pay");
printf ("\n Enter HRA");
printf ("\n Enter DA");
//calculate gross salary
printf ("\n Gross salary is = %f",gross_salary);
1) First, we include preprocessor directives such as stdio.h.
2) Start with the main function.
3) Next, we declare the variables
Basic => to store basic pay
hra => to store HRA
da => to store DA
gross_salary => to store gross salary.
4) After that, we take the user inputs which are basic pay, HRA, and DA.
5) Next, we calculate gross salary which is sum of all.
6) Print Gross salary.