Question: 1. Correct the logic/syntax error in the code below to produce the correct output, WITHOUT CHANGING ITS FLOW. 2. Explain in detail the reason/concept behind
1. Correct the logic/syntax error in the code below to produce the correct output, WITHOUT CHANGING ITS FLOW.
2. Explain in detail the reason/concept behind the error.
THE PROGRAM SHOULD PRINT THE AVERAGE OF VECTOR ELEMENTS, WHOSE SIZE AND TYPE ARE DEFINED BY THE USER.

CODE FOR REFERENCE
#include
using namespace std;
template
class A{
vector
A(vector
B=C;
}
public:
Avg avg(){
Avg sum = 0;
for(int i=0;i sum += this->B[i]; return sum/B.size(); } }; int main(){ // the type of this vector should be defined by user input, by "cin>>" vector A a(numbers); int size; int val; cout cin>>size; cout for(int i=0;i cout cin>>val; numbers.push_back(val); } cout return 0; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
