10. Arrays

Exercises

Note: whenever the problem states that program has to read in different numbers, then the program does not need to verify that the input numbers are indeed different. In describing the allowed input data, the problem description limits the possible inputs.

  1. Write a program that reads in 7 numbers, then prints out all the input values that are smaller than 10.
  2. Write a program that reads in 7 numbers, then prints out all the input values that are not equal to the smallest one. If you need a hint, see the footnote[*].
  3. Write a program that reads in 7 numbers, then prints out the sum of all the input values that are not equal to the smallest one.
  4. Write a program that reads in a natural number n and then reads in n numbers. It should print out the sum of all the given n numbers that are smaller than the last given number.
  5. Write a program that reads in 8 different numbers, then writes out the position of the smallest one in the input sequence as a number from 1 to 8. If you need a hint, see the footnote[*].

Click here for solutions