Assume the following main module is in a program that includes the binarySearch function that was shown in this chapter. Why doesn’t the pseudocode in the main module work?
// This program uses the binarySearch function to search for a
// name in the array. This program assumes the binarySearch
// function has already been defined.
Module main()
Constant Integer SIZE = 5
Declare String names[SIZE] = "James", "Marc", "Pam", "Susan", "Zack"
Declare String searchName
Declare Integer index
Display "Enter a name to search for."
Input searchName
Set index = binarySearch(names, searchName, SIZE)
If index = -1 Then
Display searchName, " was found."
Else
Display searchName, " was NOT found."
End If
End Module
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps
- This program will display an array being passed to a function, show. The show function will display the elements of the given array. The main program controls the size and the inputs of an array. // function prototype void show(int [], int); int main(){ const int arraysize=5; int numbers[arraysize]={3,6,12,7,5}; show(numbers,arraysize); // (A) show(numbers,arraysize+1); return 0;} //function body void show(int nums[], int size){ for (int index=0;index<size; index++) cout<<nums[index]<<endl; } What is the output of this program? What is the output if modification (A) has been made?arrow_forward1- Write a user-defined function that accepts an array of integers. The function should generate the percentage each value in the array is of the total of all array values. Store the % value in another array. That array should also be declared as a formal parameter of the function. 2- In the main function, create a prompt that asks the user for inputs to the array. Ask the user to enter up to 20 values, and type -1 when done. (-1 is the sentinel value). It marks the end of the array. A user can put in any number of variables up to 20 (20 is the size of the array, it could be partially filled). 3- Display a table like the following example, showing each data value and what percentage each value is of the total of all array values. Do this by invoking the function in part 1.arrow_forwarduse c++ Programming language Write a program that creates a two dimensional array initialized with test data. Use any data type you wish . The program should have following functions: .getAverage: This function should accept a two dimensional array as its argument and return the average of each row (each student have their average) and each column (class test average) all the values in the array. .getRowTotal: This function should accept a two dimensional array as its first argument and an integer as its second argument. The second argument should be the subscript of a row in the array. The function should return the total of the values in the specified row. .getColumnTotal: This function should accept a two dimensional array as its first argument and an integer as its second argument. The second argument should be the subscript of a column in the array. The function should return the total of the values in the specified column. .getHighestInRow: This function should accept a two…arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education