Programming contests

50 Programming Exercise for Beginners

January 2, 2019 12:00 AM – December 31, 2019 12:00 AM

Average of Integers #3

Write a program that reads integers from the standard input and computes their average.

Input Specification

Each of the input lines contains an integer. The reading should continue until the scanned value is 0. Do not take into account this 0 value (denoting the end of the input) when calculating the average.

Output Specification

The program should write a single line to the standard output containing the average of the n numbers with a precision of two decimal places.

Sample Input

  1. -2
  2. -1
  3. 1
  4. 2
  5. 0
download as text file

Output for Sample Input

  1. 0.00
download as text file

One possible solution is available in: main.c.

Acknowledgement This work was supported by the construction EFOP-3.4.3-16-2016-00021. The project was supported by the European Union, co-financed by the European Social Fund.
University of Debrecen; Faculty of Informatics; v. 03/01/2019