STARTING OUT WITH C++ MPL
9th Edition
ISBN: 9780136673989
Author: GADDIS
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Expert Solution & Answer
Chapter 9, Problem 20RQE
Explanation of Solution
Given:
The “empName” and “empID” are the two parallel arrays of size “numEmp” which holds employee data.
Pseudocode
do //Line 1
Set temp flag to false //Line 2
for count =0 to next-to-last array subscript //Line 3
if empID[count]>empID[count+1] //Line 4
Swap empId[count] with empId[count+1]//Line5
Swap empName[count] with
empName[count+1] //Line 6
...
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Using C language
Each function deals with null terminated C-strings. You can assume that any char array passed into the functions will contain valid, null-terminated data. Your functions must have the signatures listed below.
This function returns the index in string s where the substring can first be found. For example if s is “Skyscraper” and substring is “ysc” the function would return 2. It should return -1 if the substring does not appear in the string.
int findSubstring(char *s, char substring[])
Multi Dimensional Arrays in C Program
Ask the user for the number of rows and columns of a two-dimensional array and then its integer elements.
Then, ask the user for another integer value which represents a boogeyman. A boogeyman is a value that we intend to find from a given array.
Find and output the coordinates of the boogeyman by this format:
"BOOGEYMAN LOCATED AT ROW {row_number}, COLUMN {column_number}!"
Input
1. One line containing an integer for the number of rows
2. One line containing an integer for the number of columns
3. Multiple lines containing at least one integer each line for the elements of the array
Sample
1 4 2 3
9 1 2 3
4 2 1 1
9 2 8 3
4. One line containing an integer for the boogeyman's value
Output
Print the row of the position first and then the column of the position. Note that the row and the column is 0-based (i.e. it starts at 0 and not at 1).
It is guaranteed that the boogeyman exists and only once in the 2D array.
Enter# of rows: 4
Enter…
Chapter 9 Solutions
STARTING OUT WITH C++ MPL
Ch. 9.2 - Prob. 9.1CPCh. 9.2 - Prob. 9.2CPCh. 9.2 - Prob. 9.3CPCh. 9.2 - Prob. 9.4CPCh. 9.3 - True or false: Any sort can be modified to sort in...Ch. 9.3 - Prob. 9.6CPCh. 9.3 - Prob. 9.7CPCh. 9.3 - Prob. 9.8CPCh. 9.3 - Prob. 9.9CPCh. 9.6 - Prob. 9.10CP
Ch. 9.6 - Prob. 9.11CPCh. 9.6 - Prob. 9.12CPCh. 9.6 - Prob. 9.13CPCh. 9.6 - Prob. 9.14CPCh. 9.6 - Prob. 9.15CPCh. 9 - Prob. 1RQECh. 9 - Prob. 2RQECh. 9 - Prob. 3RQECh. 9 - Prob. 4RQECh. 9 - Prob. 5RQECh. 9 - Prob. 6RQECh. 9 - Prob. 7RQECh. 9 - A binary search will find the value it is looking...Ch. 9 - The maximum number of comparisons that a binary...Ch. 9 - Prob. 11RQECh. 9 - Prob. 12RQECh. 9 - Bubble sort places ______ number(s) in place on...Ch. 9 - Selection sort places ______ number(s) in place on...Ch. 9 - Prob. 15RQECh. 9 - Prob. 16RQECh. 9 - Why is selection sort more efficient than bubble...Ch. 9 - Prob. 18RQECh. 9 - Prob. 19RQECh. 9 - Prob. 20RQECh. 9 - Prob. 21RQECh. 9 - Charge Account Validation Write a program that...Ch. 9 - Lottery Winners A lottery ticket buyer purchases...Ch. 9 - Lottery Winners Modification Modify the program...Ch. 9 - Batting Averages Write a program that creates and...Ch. 9 - Hit the Slopes Write a program that can be used by...Ch. 9 - String Selection Sort Modify the selectionSort...Ch. 9 - Binary String Search Modify the binarySearch...Ch. 9 - Search Benchmarks Write a program that has at...Ch. 9 - Sorting Benchmarks Write a program that uses two...Ch. 9 - Sorting Orders Write a program that uses two...Ch. 9 - Ascending Circles Program 8-31 from Chapter 8...Ch. 9 - Modified Bin Manager Class Modify the BinManager...Ch. 9 - Using Files-Birthday List Write a program that...Ch. 9 - Prob. 14PCCh. 9 - Using Files-String Selection Sort Modification...Ch. 9 - Using Vectors String Selection Sort Modification...
Knowledge Booster
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
- A bank’s customer records are to be stored in a file and read into a set of arrays sothat a customer’s record can be accessed randomly by account number. Create the file byentering five customer records, with each record consisting of an integer account number(starting with account number 1000), a first name (maximum of 10 characters), a last name(maximum of 15 characters), and a double-precision number for the account balance.After the file is created, write a C++ program that requests a user-input account number anddisplays the corresponding name and account balance from the file. (Hint: Read the data in thefile into an array, and then search the array for the account number.)arrow_forwardIn C++Monkey Business A local zoo wants to keep track of how many pounds of food each of its three monkeys eats each day during a typical week. Write a program that stores this information in a two-dimensional 3 × 5 array, where each row represents a different monkey, and each column represents a different day of the week. The program should first have the user input the data for each monkey. Then, it should create a report that includes the following information: Average amount of food eaten per day by the whole family of monkeys. The least amount of food eaten during the week by any one monkey. The greatest amount of food eaten during the week by any one monkey. Write functions: average() least() greatest() main()arrow_forwardIn Quick Sort, the function Partition is used to arranged the values into the S1 set and S2 set based on the pivot value. Given the following array, what is the content of the array after the function Partition finished the 1st pass assuming the pivot value is 40? array: 44 12 50 3 40 23 Question 4 options: 3 12 23 40 44 50 12 3 23 40 44 50 40 12 3 50 44 23 23 12 3 40 44 50arrow_forward
- Using C languagearrow_forwardC++ LANGUAGE Write a program that asks for two integers X and Y as input and creates two arrays with sizes X and Y using calloc. Then, ask for the elements of the two arrays using a loop of your preference and concatenate the two arrays into one. Elements in X must come first. One line containing an integer for the size of the array X Print the concatenated elements inside a pair of square brackets [ ] where each elements are separated by a comma and a space. At the end of the program, don't forget to free the memory space. Input 1. One line containing an integer for the size of the array X 2. One or more lines containing an integer for the elements of array X 3. One line containing an integer for the size of the array Y 4. One or more lines containing an integer for the elements of array Y OUTPUT: Enter size of array 1: 3 Enter element 1: 1 Enter element 2: 2 Enter element 3: 3 Enter size of array 2: 2 Enter element 1: 4 Enter element 2: 5 [1, 2, 3, 4, 5]arrow_forwarduse C++ programming language A local zoo wants to keep track of how many pounds of food each of its three monkeys eats each day during a typical week. Write a program that stores this information in a two-dimensional 3×7 array, where each row represents a different monkey and each column represents a different day of the week. The program should first have the user input the data for each monkey. Then it should create a report that includes the following information: Average amount of food eaten per day by the whole family of monkeys The least amount of food eaten during the week by any one monkey The greatest amount of food eaten during the week by any one monkey.arrow_forward
- If array A consists only of values of 0, 1, and 2, design a function that sorts A. However, sorting should be done without comparing the records' keys. We approach array A by dividing the area into three places and placing 0, 1, 2 in each place. O goes from index 0, and 2 goes from the largest index. 0 The results before and after alignment are shown below. Before alignment = {0, 1, 1, 0, 1, 2, 1, 2, 0, 0, 0, 1} After alignment = {0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2}arrow_forwardWrite a function that displays an n-by-n matrix using the following header: void printMatrix(int n)Each element is 0 or 1, which is generated randomly. Write a test program that prompts the user to enter n and displays an n-by-n matrix.arrow_forwardIn statistics the median of a set of values is the value that lies in the middle when the values are arranged in sorted order. If the set has an even number of values, then the median is taken to be the average of the two middle values. Write a function that determines the median of a sorted array. The function should take an array of numbers and an integer indicating the size of the array and return the median of the values in the array. You may assume the array is already sorted. Use pointer notation whenever possible.arrow_forward
- Task 3: Statistics using arrays: by java programming With the spread of COVID 19, the HR department in a company has decided to conduct some statistics among the employees in order to determine the number of infections according to some conditions. For each employee, they have to record the code, name, age, whether he/she was infected or no and the remaining days of leaves for him/her. You are requested to write the program that maintains the lists of details for the employees as mentioned above using the concept of arrays. The program repeats the display of a menu of services until the user decides to exit. 1. Start by initializing the employee details by reading them from the keyboard. 2. Repeat the display of a menu of 4 services, perform the required task according to the user’s choice and asks the user whether he/she wants to repeat or no. You need to choose one service from each category (‘A’,’B’,’C’,’D’) a. A. Display the total number of employees that were infected b. B.…arrow_forwardUSE C PROGRAMMING LANGUAGEarrow_forwardPython Write a Python program that performs a linear (sequential) search. Define an array of 10 non-sequential numbers. Ask the user for a number, such as "Enter a number to be found:" Search the array for the user's number. If present, display "Successful search, the element is found at position " and its position. Otherwise, display "Number not found."arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- 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
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education