Question: 1. Convert this array code to vectors- i.e replace arrays with vectors. Obtain the same functionality by the best and most compact use of VECTORS,

1. Convert this array code to vectors- i.e replace arrays with vectors.

Obtain the same functionality by the best and most compact use of VECTORS, but do not change the flow of the program.

#include

using namespace std;

template

Avg avg(Avg arr[], int size){

Avg sum = 0;

for(int i=0;i

sum += arr[i];

return sum/size;

}

1. Convert this array code to vectors- i.e replace arrays with vectors.

code for reference:

int main(){

int ar1[5];

double ar2[5];

float ar3[5];

int choice;

do{

cout

cin>>choice;

cout

if(choice==1){

for(int i=0;i

cin>>ar1[i];

}

cout(ar1, 5)

}

else if(choice==2){

for(int i=0;i

cin>>ar2[i];

}

cout(ar2, 5)

}

else if(choice==3)

{

for(int i=0;i

cin>>ar3[i];

}

cout(ar3, 5)

}

cout

cin>>choice;}while (choice!=0);

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!