Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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;

}

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Samsung Galaxy S23 Ultra Comprehensive User Manual

Authors: Leo Scott

1st Edition

B0BVPBJK5Q, 979-8377286455

More Books

Students also viewed these Databases questions

Question

What are the health and safety conditions?

Answered: 1 week ago

Question

Explain walter's model of dividend policy.

Answered: 1 week ago

Question

What do you think of the MBO program developed by Drucker?

Answered: 1 week ago