Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please do in C++ Vectors are similar to arrays, but they can grow dynamically in an efficient way. Write a program that asks the user
Please do in C++
Vectors are similar to arrays, but they can grow dynamically in an efficient way. Write a program that asks the user to repeatedly enter positive integers and stop when the user enters -1. You need to use a vector in this question. At the beginning of the program, the vector is empty. Then, as the user enters values, the vector will be updated based on the following conditions in this order: If the vector is empty, insert the user input value into the vector If the vector is not empty and the input value is divisible by 5, then remove an element from the front of the vector If the vector is not empty and the user input value is divisible by 3, then remove an element from the end of the vector Otherwise, insert the input value at the end of the vector. After the user is done entering values, your program should display all elements in the vector, in order, separated by spaces. On the next line, it also displays the minimum value and the maximum values in the vector. START Get input from the user. Add number to the vector. YES Is the input 'a' or ''? Is the vector empty? YES Remove first element YES Na Print vector contents. Is the number divisible by 52 Remove last element. YES NO Is the number divisible by 32 END Add number to the vector. Sample run 1 (bold is user input) Please enter a number: Please enter a number: Please enter a number: Please enter a number: Please enter a number: Please enter a number: 10 Please enter a number: -1 The elements in the vector are: 7 8 Min = 7 Max = 8
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