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
thumb_up100%
int main() { int inStock[10][4]; int alpha[20]; int beta[20]; int gamma[4] = {11, 13, 15, 17}; int delta[10] = {3, 5, 2, 6, 10, 9, 7, 11,1, 8};. . .}
a. Write the definition of the function setZero that initializes any onedimensional array of type int to 0.
b. Write the definition of the function inputArray that prompts the user to input 20 numbers and stores the numbers into alpha.
c. Write the definition of the function doubleArray that initializes the elements of beta to two times the corresponding elements in alpha. Make sure that you prevent the function from modifying the elements of alpha.
d. Write the definition of the function copyGamma that sets the elements of the first row of inStock to gamma and the remaining rows of inStock to three times the previous row of inStock. Make sure that you prevent the function from modifying the elements of gamma.
e. Write the definition of the function copyAlphaBeta that stores alpha into the first five rows of inStock and beta into the last five rows of inStock. Make sure that you prevent the function from modifying the elements of alpha and beta.
f. Write the definition of the function printArray that prints any onedimensional array of type int. Print 15 elements per line.
g. Write the definition of the function setInStock that prompts the user to input the elements for the first column of inStock. The function should then set the elements in the remaining columns to two times the corresponding element in the previous column, minus the corresponding element in delta.
h. Write C++ statements that call each of the functions in parts a through g.
i. Write a C++ program that tests the function main and the functions discussed in parts a through g. (Add additional functions, such as printing a two-dimensional array, as needed.)
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps
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
- Part 2: Unroll Write a function called unroll, which takes in a square array of arrays (i.e. a grid with n rows and n columns). An input could look like this: const square = [ [1, 2, 3, 4], [5, 6, 7, 8], ]; [9, 10, 11, 12], [13, 14, 15, 16] unroll should take in such a square array and return a single array containing the values in the square. You should obtain the values by traversing the square in a spiral: from the top- left corner, move all the way to the right, then all the way down, then all the way to the left, then all the way up, and repeat. For the above example, unroll should return [1, 2, 3, 4, 8, 12, 16, 15, 14, 13, 9, 5, 6, 7, 11, 10].arrow_forwardIn C++,arrow_forwardIn C programming: Write a main() function using the following requirements:• Define a SIZE constant (the value is irrelevant, but for testing, you may want to keep it small enough – no bigger than 5)• Create an array of course pointers using SIZE• Dynamically allocate each element of the array• Call inputAllCourses()• Call printAllCourses().arrow_forward
- Use mathematical induction to show that when n ≥ 2 is an exact power of 2, the solution of the recurrence 2 = {²T (m/2) T(n) = if n = 2, 2T (n/2) +n ifn > 2 is T(n) = n lgn.arrow_forwardC#arrow_forwardWhat does the function f do? struct Point2D { double x; double y; struct Triangle { Point2D v1; Point2D v2; Point2D v3; }; void f(Triangle&t) { } int temp = 12.5; temp = t.v1.x; t.v1.x = t.v1.y; t.v1.y = temp; } int main () { Triangle mytri; mytri.v1.x = 1.0; mytri.v1.y = 22.5; f (mytri); Swaps values of x and y in vertex 1 of an argument of type Triangle Initializes value of x in vertex 1 of an argument of type Triangle Sets all x,y values in all vertices of an argument of type Triangle Swaps value of x in vertex 1 with value of x in vertex 2, for an argument of typearrow_forward
- //Required Functionvoid func(int array_1[],int array_2[],int size){ for(int i=0;i<size;i++){ if(array_2[i]>array_1[i]){ array_1[i]=array_2[i]; } } return;} //main function to test the function.int main(){ int size=6; int a[]={1,5,9,8,7,6}; int b[]={1,4,10,12,7,15}; printf("First array before function call: "); for(int i=0;i<size;i++){ printf("%d ",a[i]); } func(a,b,size); //call to the created function printf("\nFirst array after function call: "); for(int i=0;i<size;i++){ printf("%d ",a[i]); } return 0;} 1. Write the statements to do the following: write a prototype for your function in the previous problem write a main function which includes the following steps declare two arrays of ints with 25 elements each prompt the user and read values into both arrays call your function from the previous problem print both arraysarrow_forwardmatlab codearrow_forwardTopical Information Use C++. This lab will help you practice with dynamic memory (NOT mixed with classes). Program Information Heat flow through a rod can be simulated fairly easily in a computer program. We can simulate the rod using an array of temperatures. The rod begins all at the same temperature (user determined), but holding some position(s) of the rod at constant temperature (holding a match or ice cube to the rod) provides a [set of] heat source(s) (or sink(s)). To update the temperature at each time step (second?), you take the average of the positions on each side from the previous time step (and at the current position). For instance, if the following was the initial state of the rod: +------+------+------+------+------+------+------+------+ | 10 | 10 | 10 | 10 | 10 | 10 | 10 | 10 | +------+------+------+------+------+------+------+------+ And then the user specifies that there is a heat source at the left end of 100 degrees:…arrow_forward
- Write the function lastOf which searches the array a for the last occurance of any value contained in the array b. Returns the index if found. If not found, return -1. arrays.cpp 1 #include 2 3 int lastof(const int a[), int alen, const int b[], int blen) 4 { int res = 0; for (int i = 0; i =0 ; j--) if (b[j] == a[i]) { if(res[1, 9, 4, 5, 1, 5, 1, 12, 8, 11, 2, 11, 7, 8] b1->[7, 5, 9] last0f(al, 14, b1, 3): -1 Expected: 12 al->[1, 9, 4, 5, 1, 5, 1, 12, 8, 11, 2, 11, 7, 8] b2->[7, 7] lastof (al, 14, b2, 2): -1 Expected: 12 a2->[3, 2, 1, 14, 10, 6, 13, 1ө, 11, 13, 14] b2->[7, 7] lastof (a2, 11, b2, 2): -1 Expected: -1 а2->[3, 2, 1, 14, 10, 6, 13, 1ө, 11, 13, 14] b1->[7, 5, 9] last0f (a2, 11, b1, 3): -1 Expected: -1 а2->[3, 2, 1, 14, 10, 6, 13, 10, 11, 13, 14] b3->[11, 2, 1, 15] lastof (a2, 11, b3, 4): -1 Expected: 8 Score 2/5arrow_forwardC++arrow_forwardIn java there must be at least two calls to the function with different arguments and the output must clearly show the task being performed. (ONLY ARRAYS or ARRAYLIST) Develop a function that accepts an array and returns true if the array contains any duplicate values or false if none of the values are repeated. Develop a function that returns true if the elements are in decreasing order and false otherwise. A “peak” is a value in an array that is preceded and followed by a strictly lower value. For example, in the array {2, 12, 9, 8, 5, 7, 3, 9} the values 12 and 7 are peaks. Develop a function that returns the number of peaks in an array of integers. Note that the first element does not have a preceding element and the last element is not followed by anything, so neither the first nor last elements can be peaks. Develop a function that finds the starting index of the longest subsequence of values that is strictly increasing. For example, given the array {12, 3, 7, 5, 9, 8,…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