CSCI 1301 – Lab 26

Clément Aubert

November 26, 2018

Array Algorithms

Write a program that

  1. declares an array myArray of int of size 10,
  2. intitializes myArray with ten values of your choice (one of them should be 5),
  3. displays the content of myArray,
  4. displays the greatest value in myArray,
  5. displays the lowest value in myArray,
  6. displays the average of the values in myArray,
  7. display true if the number 5 occurs in myArray, false otherwise,
  8. display the smallest index where the number 5 occurs in myArray,  − 1 otherwise,
  9. display true if every number in myArray occurs exactly once.

An example of execution could be:

The content of the array is: 0 3 5 -3 10 5 7 8 9 123
The greatest value in the array is: 123
The lowest value in the array is: -3
The average of the values in the array is: 16.7
The number 5 occurs in the array: true
The smallest index where the number 5 occurs is: 2
Every number occurs exactly once in the array: false

Once this works, change the values in the array and make sure your program has the right output.

Array Algorithms: Pushing Further (Optional)

Continue working on your program, and add portion of code that

  1. display the first index where the lowest value of myArray occurs,
  2. display the last index where the greatest value of myArray occurs,
  3. declare a second array of int, and fills it with values,
  4. display true if the second array is of the same size as myArray,
  5. display true if the second array has at least one value in common with myArray.