Answered step by step
Verified Expert Solution
Question
1 Approved Answer
use c++ and explain code. thanks Question 6: In this question, you will write two versions of a program that reads from the user a
use c++ and explain code. thanks
Question 6: In this question, you will write two versions of a program that reads from the user a sequence of positive integers ending with -1, and another positive integer num that the user wishes to search for. The program should then print all the line numbers in sequence entered by the user, that contain num, or a message saying that num does not show at all in the sequence. Your program should interact with the user exactly as it shows in the following example: Please enter a sequence of positive integers, each in a separate line. End you input by typing -1. 13 100 OOI ON OO Please enter a number you want to search: 5 shows in lines 2, 6. a) The first version of the program, is not allowed to use the vector data structure. b) The second version of the program, should use the vector data structure. Implementation requirements (for both programs): 1. Think how to break down your implementation to functions. 2. Your programs should run in linear time. That is, if there are n numbers in the input sequence, your program should run in O(n). 3. Write the two programs in two functions named main1 () and main2 (). Also have the main () test these two functionsStep 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