C Program to Calculation of Bonus using 'if' statement

How to write a C Program to Calculation of Bonus using 'if' statement in C Programming Language ?


Solution:

This program is nothing but the demonstration of 'if' statement.


The current year and the year in which the employee joined the organization
are entered through the keyboard.

If the number of years for which the employee has served the organization is greater than 3 then a bonus of Rs. 2500/- is given to the employee.

If the years of service are not greater than 3, then the program should not do anything.

If his basic salary is less than Rs. 1500, then HRA=10% of basic salary and DA=90% of basic salary.

If his salary is either equal to or above Rs. 1500, then HRA = Rs. 500 and DA = 98% of basic salary.

If the employee's salary is input through the keyboard write a program to find his gross salary.


  1. #include<stdio.h>
  2. main ()
  3. {
  4.  
  5. int bonus, cy, yoj, yr_of_ser;
  6.  
  7. printf ("Enter current year and year of joining: ");
  8.  
  9. scanf ("%d %d", &cy, &yoj);
  10.  
  11. yr_of_ser = cy - yoj;
  12.  
  13. if (yr_of_ser>3)
  14. {
  15. bonus = 2500;
  16.  
  17. printf ("Bonus = Rs. %d", bonus);
  18. }
  19. }


Learn More :