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++ (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)
- you 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_forwardTrying to colve this arrays assingment, the programming language is c++ could you help? Thanks!arrow_forwardWrite a function that determines the average of the values in an array. In the main() function declare a floating point array with a length of 8 elements, and have the user enter the value of each element using a loop. The program should then call and pass the array to the function, then display the average.arrow_forward
- using c++ Create a function that accepts the integer array described above returns the standard deviation of the values in a. The standard deviation is a statistical measure of the average distance each value in an array is from the mean. To calculate the standard deviation, (http://en.wikipedia.org/wiki/Standard_deviation ) you first call a second mean function that you need to write (do not use a built in gadget. Then sum the square of the difference of each value in the array a and that mean. The standard deviation is the square root of that sum divided by the number of elements in the array. Pay attention to what type of function your standard deviation and mean functions should be. As part of testing the functions, your main should display your test array in a square. (create an integer array with 100 randomly generated values between 0 and 99; pass this array into all subsequent functions. Place code in your main to call all the methods and demonstrate they work correctly.)arrow_forwardcreate a flowchart from the user-defined array for any size n determined/chosen by the user to the function that determines the perfect squares in an array. Display theresult as an ordered pair (u, v) where u is a perfect square and v is its corresponding squareroot. Call this function to find all perfect squares of the array.arrow_forwardWrite a program that uses a two-dimensional array to store the highest and lowest temperatures for each month of the year. The program should output the average high, average low, and the highest and lowest temperatures for the year. Your program must consist of the following functions: Part a: Function getData: This function reads and stores data in the two- dimensional array. Part b: Function averageHigh: This function calculates and returns the aver- age high temperature for the year. Part c: Function averageLow: This function calculates and returns the average low temperature for the year. Part d: Function indexHighTemp: This function returns the index of the highest high temperature in the array. Part e: Function indexLowTemp: This function returns the index of the lowest low temperature in the array. (These functions must all have the appropriate parameters.) #include <iostream> using namespace std; const int NO_OF_MONTHS = 12; void getData(int twoDim[][2], int…arrow_forward
- Write down a function that will take an array, its size and an integer M as parameters and return the summation of integers that are greater than M. Then write a main function that asks the user to enter an integer X and N integers. Store N integers in an array and use the above function to compute the summation of the integers that are greater than X and display the resultarrow_forwardWrite a function that accepts an int array and the array’s size as arguments. The function should create a new array that is twice the size of the argument array. The function should copy the contents of the argument array to the new array, and initialize the unused elements of the second array with 0. The function should return a pointer to the new array. Demonstrate the function by using it in a main program that reads an integer N (that is not more than 50) from standard input and then reads N integers from a file named data into an array. The program then passes the array to your array expander function, and displays the values of the new expanded array, one value per line. You may assume that the file data has at least N values. There are no prompts for the integer and no labels for the expanded reversed array that is printed out. If the integer read in from standard input exceeds 50 or is less than 0 the program terminates silently.arrow_forwardHelp me write a program that utilizes two functions for input and output. The first function, readChars( ) prompts the user for a count and reads in count characters from the keyboard into a data array. The characters are space delimited. The second function, printReverse( ), prints the characters out in reverse order. All array bounds must be checked. The maximum character count is 25. If the user enters a value greater than 25, an error should be output and the program should exit. Notes: main( ) should only contain variable declarations and the calls to the two functions. All user input output must be performed in the functions. The following is an example of how the program should run: How many chars: 7 a 1 b 2 c 3 d d 3 c 2 b 1 a How many chars: 53 Error-max chars 25arrow_forward
- You are required to ONLY write the code for the body of a function that takes as input a 1D array and it size, and returns an array result.. You MUST NOT write the main subroutine nor add any other functions. Your code inside the function accepts two values from the user. The first value N is an integer number of elements to work on from the array, and the second is a character operation code. • If the number N is larger than the array size or negative, the code should output wrong • If the operation code is invalid, the code should output invalid If the operation code is @: you are required to count the even numbers in odd-numbered elements and print the count on the screen. • If the operation code is &: You are required to multiply each value by the one to its right and store it at the corrosponding location inside the array result. The last element remains the same. The code will print the new array on one line with each number separated by exactly one space.arrow_forwardWrite a program that stores first n prime numbers in a two-dimensional integer array. You should ask user to input row and column values of two-dimensional array. You should also write a function isPrimeNumber to check whether a number is a prime number or not. First n prime numbers should be found by multiplying row and column values entered by a user. Finally display the two dimensional array in a pretty form in reverse order of prime numbers. Note: You should NOT use built-in functions (except the most common ones) for finding prime numbers or displaying results.arrow_forwardWrite a program that creates a 2D array of integers of size nXn initialized with test data.The program should have the following functions:● getTotal. This function should accept a 2D array as an argument and returnthe total of all the values in the array.● getAverage. This function should accept a 2D array as an argument and returnthe average of all the values in the array.● getRowTotal. This function should accept a 2D array as the first argument andan integer as its second argument. The second argument should be the subscriptof a row in the array. The function should return the total of the values in thespecified row.● getColumnTotal. This function should accept a 2D array as the first argumentand an integer as its second argument. The second argument should be thesubscript of a column in the array. The function should return the total of thevalues in the specified column.● getHighestInRow. This function should accept a 2D array as the firstargument and an integer as its second…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