CSC133 Introduction to CS Using C++
Lab 10

Part I

Write a program which will do the following. Make sure you use functions in your program. Do not use any global variables.

  1. Read numbers from the keyboard into an array. Stop reading when the user enters -999. Make your array large enough to allow the user to enter up to 30 numbers.
  2. Compute the average of the numbers entered.
  3. Print out those numbers in the array which are greater than the average.
  4. Write a function which will print out the numbers in the array. The function should have a parm which indicates the order in which to print the values. If this parm contains the value 1, print the array from beginning to end. If this parm contains the value -1, print the array from end to beginning. Make sure the function only prints the array positions that were filled with the user's input. The function should print one number on each line. Use this function to print the array forwards and backwards. Print a message before calling the function to describe what is being printed.
  5. Write a function which will return the number of entries in the array which contain zero. Use this function to print the number of zeros in the array.
  6. Write a function which will return true if all the numbers in the array are positive (greater than zero) and will return false if any number in the array is not positive (less than or equal to zero). Use the function to print a message indicating whether all the values in the array are positive.

Part II

Write a program which has 3 arrays, each of which can hold 10 integers. Read 10 numbers into the first array. After reading in the 10 numbers, copy all the even numbers in the first array into the second array and all the odd numbers in the first array into the third array. Then print the numbers stored in all three arrays.

Make sure you use functions in your program. Do not use any global variables.


Email Me | Office Hours | My Home Page | Department Home | MCC Home Page

© Copyright Emmi Schatz 2002