Program 8-2
Post date: Apr 10, 2013 7:50:19 AM
Program 8-2
1 // This program stores employee work hours in an int array. It uses
2 // one for loop to input the hours and another for loop to display them.
3 #include <iostream>
4 using namespace std;
5
6 int main()
7 {
8 const int NUM_EMPLOYEES = 6;
9 int hours[NUM_EMPLOYEES]; // Holds hours worked for 6 employees
10 int count; // Loop counter
11
12 // Input hours worked by each employee
13 cout << "Enter the hours worked by " << NUM_EMPLOYEES
14 << " employees: ";
15
16 for (count = 0; count < NUM_EMPLOYEES; count++)
17 cin >> hours[count];
18
19 // Display the contents of the array
20 cout << "The hours you entered are:";
21
22 for (count = 0; count < NUM_EMPLOYEES; count++)
23 cout << " " << hours[count];
24
25 cout << endl;
26 return 0;
27 }
//Output
Program Output with Example Input Shown in Bold
Enter the hours worked by 6 employees: 20 12 40 30 30 15[Enter]
The hours you entered are: 20 12 40 30 30 15