In this tutorial you will learn about the C Program to Calculate Bonus & Gross using Basic Salary and its application with practical example.
C Program to Calculate Bonus & Gross using Basic Salary
In this tutorial, we will learn to create a C program that will Calculate bonuses & Gross using Basic Salary using C programming.
Prerequisites
Before starting with the tutorial we assume that you are best aware of the following C programming topics:
- Operators in C Programming.
- Basic Input and Output function in C Programming.
- Basic C programming.
- Conditional statement in C programming.
Program to Calculate bonuses & Gross using Basic Salary
In c programming, it is possible to take numerical input from the user and calculate the bonus & Gross using Basic Salary with the help of a very small amount of code. The C language has many types of header libraries which has supported function in them with the help of these files the programming is easy.
Algorithm:-
With the help of this program, we can Calculate the bonus & Gross using Basic Salary.
1 2 3 4 5 6 7 8 9 |
1. Declaring the variables for the program. 2. Taking the input salary of the employee. 3. Calculating the bonus salary for the employee. 4. Calculating the gross salary for the employee. 5. Printing the combined salary of the user. |
Program :-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
#include<stdio.h> int main() { //Declaring the variables for teh program float basic, bonus, gross; //taking the basic salary from the user printf("Enter basic salary of the Employee: "); //scanning the input from the user scanf("%f", &basic); //calculating the bonus salary for the employee bonus = (basic*20)/100; //calculating the gross salary for the employee gross = bonus + basic; //printing the output bonus salary printf("\nBonus = %0.2f", bonus); //printing the output gross salary printf("\nGross = %0.2f", gross); return 0; } |
Output:-
In the above program, we have first initialized the required variable.
- basic = it will hold the float value for the basic salary.
- bonus = it will hold the float value for the bonus salary.
- gross = it will hold the float value for the gross salary.
Input salary for the employee.
Bonus Salary for the employee.
Printing output for salary for the employee.