/* * Example of the ``while'' statement * * Compute the payroll for a company * Hanly and Koffman, 5ed, Figure 5.4, page 217 */ #include int main(void) { int number_emp, count_emp; double total_pay, hours, rate, pay; 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("Hours> "); scanf("%lf", &hours); printf("Rate > $"); scanf("%lf", &rate); pay = hours * rate; printf("Pay is $%6.2f\n\n", pay); total_pay = total_pay + pay; count_emp = count_emp + 1; // count_emp += 1; /* compound assignment operators */ } printf("All employees processed\n"); printf("Total payroll is $%8.2f\n", total_pay); return (0); }