Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that follows the steps below: 1. input 6 numbers from the user -user inputs numbers one at a time 2. loop continuously

Write a program that follows the steps below:

1. input 6 numbers from the user

-user inputs numbers one at a time

2. loop continuously until the exit condition below:

- ask the user to search for a query number

- if the query number is in the list: reports the first location of the query number in the list, change the number in that position to 0, show the updated list

- if the query number is not in the list: exit the loop

Example execution:

$ ./a.out

Input number 1: 4

input number 2: -10

input number 3: 8

Input number 4: 22

Input number 5: -33

input number 6: 55

Enter a query number: 8

8 was at location 3

Current list: 4 -10 0 22 -33 55

Enter a query number: -10

-10 was at location 2

Current list: 4 0 0 22 -33 55

Enter a query number: 53

53 not in list!

Goodbye!

$

*********

notes: i was able to get the swap and everything here is my code below, but i cannot get it to work when a number is not there in the listimage text in transcribed

1 //Katie Mays 2 //Dec. 7, 2017 3 //LAB9: number search and query 4 5 #include 6 using namespace std; 7 8 // prototypes 9 void swap (int , int) 10 11 int main() 12 13 14 15 16 17 18 19 20 21 /I variables int integers [6]={0}, query; // input for (int i =0; i > integers[i]; 23 24 25 26 27 28 29 // processing and output for (int i 0; i > query swap(integers, query); 31 32 cout

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_2

Step: 3

blur-text-image_3

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

C++ Database Development

Authors: Al Stevens

1st Edition

1558283579, 978-1558283572

More Books

Students also viewed these Databases questions

Question

How wide are Salary Structure Ranges?

Answered: 1 week ago