Question
// This program demonstrates the vector's empty member function. #include #include using namespace std; // Function prototype double avgVector(vector ); int main() { __________________ //
// This program demonstrates the vector's empty member function.
#include
#include
using namespace std;
// Function prototype
double avgVector(vector
int main()
{
__________________ // A vector to hold values
int numValues; // The number of values
double average; // To hold the average
// Get the number of values to averge.
cout << "How many values do you wish to average? ";
cin >> numValues;
// Get the values and store them in the vector.
for (int count = 0; count < numValues; count++)
{
____________________; //fill in the blank
____________________;
____________________;
____________________;
}
// Get the average of the values and display it.
average = avgVector(values);
cout << "Average: " << average << endl;
return 0;
}
//*************************************************************
// Definition of function avgVector. *
// This function accepts an int vector as its argument. If *
// the vector contains values, the function returns the *
// average of those values. Otherwise, an error message is *
// displayed and the function returns 0.0. *
//*************************************************************
double avgVector(vector
{
int total = 0; // accumulator
double avg; // average
if (__________________) // Determine if the vector is empty
{
________________________;
________________________;
}
else
{
__________________________;
____________________________;
____________________________;
}
return avg;
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started