Skip to content

section8_exercises

Fábio Gaspar edited this page Jan 18, 2019 · 1 revision

Exercises

  1. Write a program that asks 10 numbers. These numbers should be stored in an array. Then, write a function that adds all values, another to find the average, another to find the maximum and another to find the minimum value. The program should output the results (sum, average, maximum value or minimum value).
Insert numbers:
1 2 3 4 5 6 7 8 9 10

Sum: 55
Average: 5.5
Maximum: 10
Minimum: 1
  1. Write a function that reverses an array and outputs the reversed array.

  2. Write a program for storing the temperature of two cities for a week. The input should come from the user and you should display the the temperatures of both cities in fahrenheit [°C = (°F - 32)/1,8].

============
City 1
============
Day 1: 0
Day 2: 40
Day 3: 52.3
Day 4: 60
Day 5: 45.4
Day 6: 42
Day 7: 48

============
City 2
============
...