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; } 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
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