Skip to content

CGreenP/NPTEL-Programming-Assignment-T2-Q1

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

NPTEL-Programming-Assignment-T2-Q1

NPTEL Programming Assignment: T2-Q1

T2-Q1

You are given a non-empty sequence of non-negative integers terminated by a -1. The -1 is not part of the input sequence. The sequence has length at most 100, including the -1. There will be at least one non-negative number.

You have to output the sequence of running averages, where:

The first average is the first input number.

The second output is the average of the first two input numbers.

The third output is the average of the first three input numbers, and so on.

Output Format: You should output exactly 2 digits after the decimal place. Different numbers in the output should be separated by spaces. At the end, you should print a newline.

Sample input 1

0 0 0 0 -1

Sample output 1

0.00 0.00 0.00 0.00\n

Sample input 2

4 6 2 0 -1

Sample output 2

 4.00 5.00 4.00 3.00\n

Sample input 3

4 2 0 -1

Sample output 3

4.00 3.00 2.00\n

Sample input 4

2 2 2 2 2 2 2 -1

Sample output 4

2.00 2.00 2.00 2.00 2.00 2.00 2.00\n