Program 8-1

Post date: Apr 10, 2013 7:49:45 AM

Program 8-1

1 // This program stores employee work hours in an int array.

2 #include <iostream>

3 using namespace std;

4

5 int main()

6 {

7 const int NUM_EMPLOYEES = 6;

8 int hours[NUM_EMPLOYEES]; // Holds hours worked for 6 employees

9

10 // Input hours worked by each employee

11 cout << "Enter the hours worked by " << NUM_EMPLOYEES

12 << " employees: ";

13 cin >> hours[0];

14 cin >> hours[1];

15 cin >> hours[2];

16 cin >> hours[3];

17 cin >> hours[4];

18 cin >> hours[5];

19

20 // Display the contents of the array

21 cout << "The hours you entered are:";

22 cout << " " << hours[0];

23 cout << " " << hours[1];

24 cout << " " << hours[2];

25 cout << " " << hours[3];

26 cout << " " << hours[4];

27 cout << " " << hours[5] << endl;

28 return 0;

29 }

//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