In a company an employee is paid as under: If his basic salary is less than 5000 then he’ll get 10% of his base salary as HRA and 90% of his base salary as DA. If his basic salary is above 5000, then he’ll get 600 HRA and 95% of his base salary as DA.
HRA – House Rent Allowance.
DA – Dearness Allowance.
C Program to Calculate Gross Salary of an Employee
[youtube https://www.youtube.com/watch?v=qqbhNjWedLw]
YouTube Link: https://www.youtube.com/watch?v=qqbhNjWedLw [Watch the Video In Full Screen.]
Source Code: Calculate Gross Salary of an employee
- #include < stdio.h >
- int main()
- {
- float bs, gs, da, hra;
- printf("Enter basic salary\n");
- scanf("%f", &bs);
- if( bs < 5000 )
- {
- hra = bs * 10 / 100;
- da = bs * 90 / 100;
- }
- else
- {
- hra = 600;
- da = bs * 95 / 100;
- }
- gs = bs + da + hra;
- printf("Gross Salary is Rs %f\n", gs);
- return 0;
- }
Output 1:
Enter basic salary
5500
Gross Salary is Rs 11325.000000
Output 2:
Enter basic salary
4000
Gross Salary is Rs 8000.000000
Formula to calculate Gross Salary is:
Gross Salary = Basic Salary + Dearness allowance + House Rent Allowance.
For full C programming language free video tutorial list visit:C Programming: Beginner To Advance To Expert