Hi, im learning about floating point values right now. I understand how they are used in averages and other numbers with a decimal. i also know they dictate between types like double and int. But my homework is asking to write a program that reads a set of floating point values. then ask the user to enter tha values and print:
-the average of the values
-the smallest of the values
-the largest of the values
-the range
I have the smallest and largest. I put what i thought the average and range should be. This is what i have so far
#include <iostream>
using namespace std;
int main()
{
double total = 0.0;
int count = 0.0;
double input;
while (cin >> input)
{
total = total + input;
count++;
}
double average = 0.0;
if (count > 0)
{
average = total / count;
}
double smallest;
cin >> smallest;
double input;
while (cin >> input)
{
if (input < smallest)
{
smallest = input;
}
}
double largest;
cin >> largest;
double input;
while (cin >> input)
{
if (input > largest)
{
largest = input;
}
}
double input;
double smallest;
cin >> smallest
double largest;
cin >> largest;
double range = 0.0
range = largest - smallest
while (largest > smallest)
{
cout << range, endl;
}
return;
I was hoping i could get some help with the average and range. I know what they are supposed to say, but im not sure how exctly to put it. Thanks in advance.