Write a function named swapFrontBack that takes as input an array of integers and an integer that specifies how many entries are in the array. The function should swap the first element in the array with the last element in the array. The function should check if the array is empty to prevent errors. Test your function with arrays of different length and with varying front and back numbers.
Want to see the full answer?
Check out a sample textbook solutionChapter 7 Solutions
Problem Solving with C++ Plus MyLab Programming with Pearson eText -- Access Card Package (10th Edition)
Additional Engineering Textbook Solutions
Starting Out with Python (3rd Edition)
Software Engineering (10th Edition)
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Web Development and Design Foundations with HTML5 (9th Edition) (What's New in Computer Science)
Differential Equations: Computing and Modeling (5th Edition), Edwards, Penney & Calvis
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
- Write a function called largest_sum_sequence() that accepts an array of signed integers and the number of items in the array as parameters, and returns the largest sum of a sequence of numbers in the array. A sequence is defined as a single item or multiple items that are in consecutive adjacent memory locations. Example 1: 9 3 -1 7 -12 largest sum in sequence is 18 [9, 3, -1, 7] Example 2: -77 3 -2 1 largest sum in sequence is 3 [3]arrow_forwardyou need to insert only the even index values to an array named intArray[]. Now send that array to a function named int sumOfallArrayElements(int *intArrayLocal) where you need to sum all the elements of all the array elements and return back to the main function. PLEASE DO NOT USE ANY INDEX TO ACCESS ELEMENTS OF THE ARRAY. Sample Output:Elements of intArray: 0 2 4 6 8 10 12 14 16 18Sum of all evenindex elements is: 40arrow_forwardSet up a user defined function for finding square root If the supplied number is not negative the function should find the square root of the value passed value using the proper Numpy function and return it rounded to 3 decimal places. If the passed number is negative, then the function should return a string with the value of the square root of the positive portion of the number concatenated with the letter ‘i’ to the right Set seed to 1 and create a Numpy array of 6 randomly generated integer numbers between -10 to 10 Iterate over the values of the Numpy array prepare a report, Use f-string formatting and Use the user defined function for the Square-root column Column names: Row, Number, Running Sum, and Square-rootarrow_forward
- Write a function named "reverse" that takes as its arguments the following: (1) an array of floating point values; (2) an integer that tells how many floating point values are in the array. The function must reverse the order of the values in the array. Thus, for example, if the array that's passed to the function looks like this: 0 1 2 3 4 5.8 2.69.0 3.417.1 then when the function returns, the array will have been modified so that it looks like this: 0 1 2 3 4 7.13.49.0 2.6 5.8 The function should not return any value.arrow_forwardWrite a function called remove_punct() that accepts an array of characters and the number of items in the array as parameters, removes the punctuation (',', '!', '.') characters from the array, and returns the number of punctuation characters removed. For example, if the array contains ['C', 'p', 't', 'S', ',', '1', '2', '1', '.', 'i', 's', 'f', 'u', 'n', '!'], then the function should remove the punctuation characters. The function must remove the characters by shifting all characters to the right of each punctuation character, left by one spot in the array. This will overwrite the punctuation characters, resulting in: ['C', 'p', 't', 'S', '1', '2', '1', 'i', 's', 'f', 'u', 'n']. In this case, the function returns 3. Note: if the array does not contain any punctuation characters, then the array is unchanged and the function returns 0.arrow_forwardWrite a function that returns an integer that appears most often with respect to an array of integers In the array. for example. [1 2 3 2 3 4 2 5] For an array your function must return 2.arrow_forward
- Write a function reportDuplicates() that takes a two di mensional integer array as a parameter and identifies the duplicate valuesin the array. The function then reports these to user. Sample input and corresponding output:How many rows? 5How many columns? 2Let’s populate the array:1 86 97 312 522 4Thank you, there are no duplicate elements!How many rows? 3How many columns? 4Let’s populate the array:3 7 5 76 9 7 38 5 12 6Thank you, 3 appears 2 times, 7 appears 3 times, 5 appears 2 times,and 6 appears 2 times.arrow_forward1. single element of an array can be passed to the function? true or false. 2. Array can be declared as constant? true or false. 3. which of the following gives the memory address of the first element in array x? a. X b. X[0] c. X{0} d. X_0 e. X(0) 4. The index of the last element of array X whose size is S? a. S+1 b. S-1 c. 0 d.1000 e. S 5. Assume you have the following declarations const int MAX = 1000;double A[MAX];which of the following sentences is incorrect? a. The assingnment statement MAX = 1000 is mandatory. b. we can store up to 1000 values in the mandatory. c we cannot change the size of the array A during the runtime. d. all values in the array are set to ZERO's (0) e. all above sentences are correct. 6. The only difference between char array and string is that, the string ends with '\0'? true or false. 7. Index of an array can be of type integer or double, since both deals with the digits? True or False 8. Which definition describes the term Array precisely?…arrow_forwardWrite a function named “isAscendingDigits” thatwill accept a C-string (an array of characters with a terminating NULL character. It will return true if the array contains the ascending digits and false otherwise. Ascending digits meanthat the arraycontains only a sequence of digits and the next digit is greater than the previous one. Again, you must use only pointer notation in your function.Please show how this function is being used and tested.arrow_forward
- Write a function that receives a two-dimensional array, prints out the data by row along with the sum of the row values. Each value should be printed separated by a space. After the last element in the row has been printed, the sum should be printed on the same line, followed by a newline.arrow_forwardWrite a program which should consists of a user defined function “Task ()”. Pass 1D array to the function, along with number of elements of array. Find out the maximum element in 1D array using this functionarrow_forwardWrite a program that dynamically allocates an array large enough to hold a user defined number of test scores. Once all the scores are entered, the array should be passed to a function that sorts them in descending order and display the sorted list. Another function should be called that calculates the average score and display in the same function. Use appropriate headings for function and pointer notation rather than array notation whenever possible. Input Validation: Do not accept negative numbers for test scorearrow_forward
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage