CPPForSchool.com: Array - Single Dimension Set 1 Assignment 7

7. Suppose a one-dimensional array AR containing integers is arranged in ascending order. Write a user-defined function in C++ to search for an integer from AR with the help of Binary search method, returning an integer 0 to show absence of the number and integer 1 to show presence of the number in the array. Function should have three parameters : (i) array AR (ii) the number to be searched and (iii) the number of elements N in the array.


It seems as if all of my submissions are quite different from the example source.  Although my program fulfills the requirements of the AR array, number searched, and the number of elements, the implementation is quite different.  Upon further inspection, the bool bsearch function is quite different than the one I implemented.  I based my bool function on the prior assignment.  However, the example source uses a different approach.  Admittedly, I am not exactly sure how to interpret the bsearch function.  Nevertheless, I have posted my source and output.  In addition, I have also included the example source and output for comparison.











Comments

Popular posts from this blog

CPPForSchool.com: Variable, Operator & Expression Set 1: Assignment 9

CPPForSchool.com: Array - Single Dimension Set 1 Assignment 6

CPPForSchool.com: Variable, Operator & Expression Set 1: Assignment 8