ole Binary Search program   Enter 0 to exit   Numbers:  13, 16, 18, 29, 3

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter8: Arrays And Strings
Section: Chapter Questions
Problem 21PE
icon
Related questions
Question
Create a program that uses an STL algorithm to perform a binary search that checks whether a number is in a sequence of sorted numbers.

Console

Binary Search program
 
Enter 0 to exit
 
Numbers:  13, 16, 18, 29, 32, 71, 71, 77, 78, 90
 
Enter a number from 1 to 100: 1
1 is NOT in numbers.
 
Enter a number from 1 to 100: 32
32 is in numbers.
 
Enter a number from 1 to 100: 100
100 is NOT in numbers.
 
Enter a number from 1 to 100: 0
Bye!

Specifications

  • The program should begin with a list of 10 integers from 1 to 100 (both inclusive).
  • The program should allow the user to enter a number from 1 to 100. Then, it should display whether that number is or isn’t in the list of numbers.
  • The program should use an STL algorithm to sort the numbers.
  • The program should use an STL binary search algorithm to search the list of numbers.  
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Concept of Parenthesis
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning