write a program to read a sorted list of floating point values and then calculate and display the average of the values
#include <iostream>
using namespace std;
int main()
{
int count;
cout << "How much floats you want to calculate? ";
cin >> count;
double float_tmp, floats_sum = 0;
cout << "Enter your floats:\n";
for (int i = 0; i < count; ++i)
{
cin >> float_tmp;
floats_sum += float_tmp;
}
cout << "\nThe average value is " << floats_sum / count;
}
Comments
Leave a comment