Design, implement, debug and test a C++ program thatwill: 1.Generate 12 random i
ID: 3616980 • Letter: D
Question
Design, implement, debug and test a C++ program thatwill: 1.Generate 12 random integers in the range of 100 to999. 2.Add each integer to vector vSmall (100-399). vMedium (400-699) orvLarge (700-999). 3.Sort each vector individually. 4.Join the three vectors into one sorted vector. 5.Display the four sorted vectors. Design, implement, debug and test a C++ program thatwill: 1.Generate 12 random integers in the range of 100 to999. 2.Add each integer to vector vSmall (100-399). vMedium (400-699) orvLarge (700-999). 3.Sort each vector individually. 4.Join the three vectors into one sorted vector. 5.Display the four sorted vectors.Explanation / Answer
please rate - thanks #include using namespace std; void sort(int[],int); void merge(int[],int,int[],int&); void print(int[],int,string); int main() {int small[12],medium[12],large[12],merged[12]; int num,cs=0,cm=0,cl=0,cmerge=0,i; srand(time(0)); for(i=0;i699) {large[cl]=num; cl++; } else if(num>399) {medium[cm]=num; cm++; } else {small[cs]=num; cs++; } } sort(large,cl); sort(medium,cm); sort(small,cs); print(small,cs,"small(100-300)"); print(medium,cm,"medium(400-699)"); print(large,cl,"large(700-999)"); merge(small,cs,merged,cmerge); merge(medium,cm,merged,cmerge); merge(large,cl,merged,cmerge); print(merged,cmerge,"merged"); system("pause"); return 0; } void merge(int a[],int n,int b[],int &m) {int i=0,j=0,k,l,done; for(i=0;iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.