CS 1620 Assignment #8 Spring 2001
The Last One
How to handin.
Due : Monday Apr 9, 2001 @ midnight
No assignments will be accepted after Apr 11, 2001 @ midnight.
- Given two integer arrays a and b, say
with 12 elements each. Write a program that performs the following:
- Input some data from the user into the two arrays.
- Output the sum of the elements in each of the two arrays.
- Output the sum of the products of corresponding elements.
a[0]*b[0]+a[1]*b[1]+ ...
- Add the contents of both arrays. The result should be
stored in a third array, say c. That is,
c[0]=a[0]+b[0], c[1]=a[1]+b[1], ...
All the three arrays must be passed as arguments to a function called
addArrays.
-
Add another function called maxMinEven to search through
the array c to find the smallest and largest
numbers. Also maxMinEven counts the number of even numbers.
-
Searches the first n
elements of an array for an element with a given value.
If the value is found then the function
should return true and also return the index of the element
in the array. If not found then the function should return
false.
- Now sort the array c using the bubble sort algorithm.
More specifically, write a function called bubbleSort that accepts
three arguments - the array c, a count of the number of elements in
the array and a boolean variableorder indicating
whether the array should be sorted in increasing or decreasing order.
The user should be able to sort in increasing or decreasing order.
- You need to write at least seven different functions to perform the tasks stated
in questions (a), (b), (c), (d), (e), (f) and (g).
- The function for question (a) should also ask for the number of elements
to be entered and should signal an error situation if this is greater than
the size of the array.
In this case your program should not perform the remaining questions.
- Write a driver program to test these functions.
!! Note: Your grade will be awarded for program correctness, readability, and documentation .
Assignment List | Prev | Computer Science 1620
Department of Mathematics & Computer
Science
University of
Lethbridge Home Page