CISC1600: Computer Science I Lab 7

Purpose: In this lab assignment of CIS1600, we will practice using array to solve a problem.

Instruction: We will write a program that prompts the user to enter 10 integers, reports the smallest value among these 10 integers, and then displays the 10 integers and their difference from the smallest value. Please name your source code as lab7.cpp.

Your program works as follows. Note that you are not required to design and implement functions in this lab, you can write all the codes in the main():

  1. Declare an array of int type with length 10.
  2. Prompt the user to enter 10 integers.
  3. Read the 10 integers into the array.
  4. Write a loop to find the smallest value in this array.
  5. Write a loop to display each of the array element, and its difference from the smallest value.

An example run of your program is as follows, where the user inputs are underlined, and the program output are shown in regular format:

$ ./a.out
Please enter 10 integers:32 30 12 3 100 29 1 42 80 90
The smallest value is 1.
All values and their difference from smallest values are:
32 31
30 29
12 11
3 2
100 99
29 28
1 0
42 41
80 79
90 89

Coding Style Requirement:

  1. Please indent your code in as required.
  2. Use descriptive names for variables
  3. Use blank lines to separate the code into appropriate blocks
  4. Be sure to include comments to help others understand your program, and help yourself think!

How to submit

Please submit your program (which has to be named lab7.cpp) to the following webpage:

Lab7 submission link.