Write a program that reads daily temperatures, as floats. Read in a loop until an EOF. After the input has been read, print the average value.
Sample input values
10.0 11.3 4.5 -2.0 3.6 -3.3 0.0The output should look something like the following. Formatting may vary.
Average = Average is 3.44286
Problem 2: Ave2.cpp
Write a complete program which reads floating point numbers from cin and computes two averages: the average of the negative numbers it reads and the average of the positive numbers it reads.
For example, for input 9 -1 -1 -4 1 the positive average would be 5 (the sum of the positive numbers (9+1) divided by the number of positive numbers (2). By a similar process the average of the negative numbers would be -2 (ie, ((-1 + -1 + -4) / 3). You don't need to write any functions for this problem.
0 Comments