C Program to Calculate and Print Bonus & Gross using Basic Salary

In this article, we will learn about how to create a program in C that will ask from user to enter his/her basic salary as input, and then compute the bonus amount (bonus will be calculated at 20% of basic salary) and gross salary using given basic salary of the employee.

int main()
    float basic, bonus, gross;
    printf("Enter basic salary of the Employee: ");
    scanf("%f", &basic);
    bonus = (basic*20)/100;
    gross = bonus + basic;
    printf("\nBonus = %0.2f", bonus);
    printf("\nGross = %0.2f", gross);
    return 0;

As the above program was written under Code::Blocks IDE, therefore after successful build and run, here is the first snapshot of the sample run:

c program calculate bonus salary

Provide the basic salary of the employee, the program will print the Bonus@20% and gross salary of the employee as shown here in the second snapshot of the sample run:

print gross bonus of basic salary c

Here are some of the main steps used in above program:

  • Receive basic salary of employee as input
  • Now Calculate the Bonus amount by applying 20 percent of the basic salary
  • And then calculate the gross salary by adding bonus and basic salary amount
  • Print the value of both bonus and gross salary amount as output
  • Here we have used the format specifier %0.2f to print only two digit after decimal

C Online Test

« Previous Program Next Program »

Follow/Like Us on Facebook

Subscribe Us on YouTube