IHYPRESS PROGRAMMING
Tutorials and C programs with code and output for beginners
c programming
HOME | ASP | C | CSS | GNUPLOT | HTML | JAVASCRIPT | PERL | PHP | PYTHON | RUBY | SVG
CLoops : Company Payroll Program
<04.11>
/* Program to Compute Company Payroll */ /* Compute the payroll for a company */ #include <stdio.h> int main(void) { double total_pay; /* company payroll */ int count_emp; /* current employee */ int number_emp; /* number of employees */ double hours; /* hours worked */ double rate; /* hourly rate */ double pay; /* pay for this period */ /* Get number of employees. */ printf("Enter number of employees: "); scanf("%d", &number_emp); /* Compute each employee's pay and add it to the payroll. */ total_pay = 0.0; count_emp = 0; while (count_emp < number_emp) { printf("Enter hours worked: "); scanf("%lf", &hours); printf("Enter hourly rate: $"); scanf("%lf", &rate); pay = hours * rate; printf("Pay is $%6.2lf\n\n", pay); total_pay = total_pay + pay; /* Add next pay. */ count_emp = count_emp + 1; } printf("All employees processed\n"); printf("Total payroll is $%8.2lf\n", total_pay); return (0); }
Hergestellt in Deutschland / Made in Germany
Enter number of employees: 3 Enter hours worked: 25 Enter hourly rate: $18.50 Pay is $462.50 Enter hours worked: 32.5 Enter hourly rate: $16.00 Pay is $520.00 Enter hours worked: 35 Enter hourly rate: $20.50 Pay is $717.50 All employees processed Total payroll is $ 1700.00
COPYRIGHT © 2015-2024 IHY PRESS Frankfurt am Main 60329 Deutschland