In this tutorial you will learn about the C Program to Calculate Wage of Labor on Daily Basis and its application with practical example.
C Program to Calculate Wage of Labor on Daily Basis
In this tutorial, we will learn to create a C program that will Calculate the Wage of Labor on a Daily Basis using C programming.
Prerequisites
Before starting with this 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.
- While loop in C programming.
- Arithmetic operations in C Programming.
Program to Calculate Wage of Labor on Daily Basis
In c programming, it is possible to take numerical input from the user and Calculate the Wage of Labor on Daily Basis 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. But today we will Calculate the Wage of Labor on Daily Basis using c programming.
As per the following rule:
1 2 3 4 5 |
Starting 8 hours 50.00 For the next 4 hours 10.00 per hour extra For the next 4 hours 20.00 per hour extra For the next 4 hours 25.00 per hour extra For the next 4 hours 40.00 per hour extra |
With the help of this program, we can Calculate the Wage of Labor on a Daily Basis.
Algorithm:-
1 2 3 4 5 6 7 8 9 10 11 12 13 |
1. Declaring the variables for the program. 2. Taking the input name of the worker. 3. Taking the working hours for the workers. 4. Checking the plans. 5. Calculating the wages 6. Printing the wages. 7. End the program. |
Program to Calculate the Wage of Labor on a Daily Basis:-
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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
#include<stdio.h> int main() { //declaring the variable for the program float initWage=50, hours, tempHour, tempWage, totalWage; char name[20]; //showing the message for the input printf("Enter Name of Employee: \t"); gets(name); printf("Enter total hours worked: \t"); scanf("%f", &hours); //checking the wages with the plans if(hours<=8) totalWage = initWage; else if(hours>8 && hours<=12) { tempHour = hours-8; tempWage = tempHour*10; totalWage = tempWage + initWage; } else if(hours>12 && hours<=16) { tempHour = hours-12; tempWage = 4*10; totalWage = initWage + tempWage + (tempHour*20); } else if(hours>16 && hours<=20) { tempHour = hours-16; tempWage = (4*10) + (4*20); totalWage = initWage + tempWage + (tempHour*25); } else if(hours>20 && hours<=24) { tempHour = hours-20; tempWage = (4*10) + (4*20) + (4*25); totalWage = initWage + tempWage + (tempHour*40); } else { printf("A single day only has 24 hours."); return 0; } // printing the wages for the workers printf("Total Wage: \t\t\t%0.2f", totalWage); return 0; } |
Output:-
In the above program, we have first initialized the required variable.
- name = it will hold the character value for the name.
- initWage = it will hold the floating value for the workers.
- hours = it will hold the floating value for the working hours.
- temphour = it will hold the floating value.
- tempWage = it will hold the floating value.
- totalWage = it will hold the floating value to calculate the wages.
Input name and hour from the user.
Program Logic Code.
Printing output for wages calculated.