Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
Using the supplied main.cpp, help me add code for the reverseNames() function. The function should accept two arrays that are parallel, and reverse the order of the strings in the array. Because the arrays are parallel, the elements should be swapped at the same time. Do not swap the pets array, then the owner array in separate loops. Do it all in a single loop in the function.
Prototypes
void reverseString( string a[ ], b[ ], int size );
Function reverseString() will reverse the order of the strings in the arrays.
The following is the main.cpp
#include <iostream>
using namespace std;
void reverseNames( string [], string [], int size);
int main(){
string pet[5] = {"Hobbs", "Snoopy", "Odie", "Garfield", "Pluto"};
string owner[5] = {"Calvin", "Charlie", "Jon", "Jon", "Mickey"};
cout << "Initial array values" << endl;
for ( int i=0; i<5; i++){
cout << pet[i] << " " << owner[i] << endl;
}
reverseNames(pet, owner, 5);
cout << endl << "After reverse" << endl;
for ( int i=0; i<5; i++){
cout << pet[i] << " " << owner[i] << endl;
}
}
void reverseNames(string a[], string b[], int size ){
}
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 3 steps with 1 images
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
- Exercise - Collection Functions Using the code below, use the map function to create an array of Int values, whose values are equal to the original integer value, plus 1. Use $0 as you iterate through the values of the array. Print the resulting collection. 5 let testScores = [65, 80, 88, 90, 47] Using the code below, use the filter function to create a new array of String values. The new array should only include Strings longer than four characters. Use $0 as you iterate through the values of the array. Print the resulting collection. Olet schoolSubjects = ["Math" , "Computer Science", "Gym", "English", "Biology"] Using the code below, use the reduce function to subtract all of the values within the array from the starting value 100. Print the resulting value. let damageTaken = [25, 10, 15, 30, 20]arrow_forwardStep 1: Read your files! You should now have 3 files. Read each of these files, in the order listed below. staticarray.h -- contains the class definition for StaticArray, which makes arrays behave a little more like Python lists O In particular, pay attention to the private variables. Note that the array has been defined with a MAX capacity but that is not the same as having MAX elements. Which variable indicates the actual number of elements in the array? staticarray.cpp -- contains function definitions for StaticArray. Right now, that's just the print() member function. 0 Pay attention to the print() function. How many elements is it printing? main.cpp -- client code to test your staticarray class. Note that the multi-line comment format (/* ... */) has been used to comment out everything in main below the first print statement. As you proceed through the lab, you will need to move the starting comment (/*) to a different location. Other than that, no changes ever need to be made to…arrow_forwardPrompt: In Python language, write a function that applies the logistic sigmoid function to all elements of a NumPy array. Code: import numpy as np import math import matplotlib.pyplot as plt import pandas as pd def sigmoid(inputArray): modifiedArray = np.zeros(len(inputArray)) #YOUR CODE HERE: return(modifiedArray) def test(): inputs = np.arange(-100, 100, 0.5) outputs = sigmoid(inputs) plt.figure(1) plt.plot(inputs) plt.title('Input') plt.xlabel('Index') plt.ylabel('Value') plt.show() plt.figure(2) plt.plot(outputs,'Black') plt.title('Output') plt.xlabel('Index') plt.ylabel('Value') plt.show() test()arrow_forward
- TASK 1. Re-write this code using Lambda. S TASK 2. Create an array2 that consists of 30987888 digits. Write a code using Lambda function to display only even numbers from array2. int[] array = { 2, 6, 4, 12, 7, 8, 9, 13, 2 }; var orderedFilteredArray = from element in array where element < 7 orderby element select element; PrintArray(orderedFilteredArray, "All values less than 7 and sorted:");arrow_forwardSection A. Declare and initialize an array myChars containing the following characters: B, C, D, A, M, S and F.Remember to choose the correct data type for the array elements.Section B. Using a WHILE loop, output the elements of the array myChars so that they are displayed on thesame line and separated by a space. Use .length to get the length of the array.Section C. Change the last value of the array myChars to the letter X. Use .length in your code.Section D. Using a FOR loop, output the elements of the myChars array so that they are displayed on the sameline and separated by a dash (an extra dash at the end is okay). Use .length in your code.Section E. Declare an array of int of capacity 10 named thisArray.Section F. Use a FOR loop to populate the array thisArray with the following numbers 5, 10, 15, 20, 25. Thinkof a way to insert these numbers without actually writing “5” or “10” and so on, but by using the variable i ofyour FOR loop. NOTE that this is a partially-filled array and…arrow_forwardTry using the ref or out keyword to pass in an array argument and see what happens.arrow_forward
arrow_back_ios
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