Exercises

Write the code to:

1.                 Declare an integer array named stuff with 20 elements

2.                 Initialize each element of the array stuff to to value 100.

3.                 Ask the user to enter each value of the array stuff (prompt and input)

4.                 Print all elements of the stuff array

5.                 Print all elements of the array stuff in reverse order

6.                 Sum all elements of the array stuff

7.                 Determine the average of all elements in the array stuff

8.                 Find the largest element in the array stuff

9.                 Subtract 1 from every element of the stuff array.

10.             Divide all even-numbered elements in the stuff array (stuff,stuff,..stuff) by 5,  i.e. stuff = stuff/5;...

11.             Give the output from the following program:

int test;

int  index;

for (index = 0; index < 10; index++)

test[index] = index * 2;

cout << test << endl;

cout << test << endl;

cout << index << endl;

12.             Set up a two dimensional array called table with 3 rows and 4 columns. (Declare it)

13.     Print the first row of table.

14.             Set up the appropriate array for a tic tac toe board

15.             Print out the tic tac toe board

For each of the following: write complete code, using an array for each.

16.             Write complete code for a program that will input (prompt the user) an array of exactly 200 characters and display to the screen a count of the occurrences of each of the vowels (a, e, i, o, u) in the array. (Five numbers in total should be displayed.)

17. Write a program that will prompt for and receive exactly 10 integers, and count the number of integers whose value is less than the average value of the integers. Your program is to display the average integer value and the count of integers less than average. Hint, you will need at least two loops.

18. Write a program that will prompt for and input up to 20 integers from the user and display to the screen the average of the integers. At any time, the user may enter 999 to stop entering numbers, at which point the average of the numbers entered so far should be displayed.