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++ (9th 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 that determines standartdeviation of float array. The function takes dataset as afloat array parameter!! And it also return result as afloat.(Clue: calculate average first) Definations: in the image σ = standard deviationxi = each value of dataset? (with a bar over it) = the arithmetic mean of the data(This symbol will be indicated as average of dataset)N = the total number of data points(if you need square root of some number you can use sqrtfunction in math.h library. Usage example: a=sqrt(b);which means “a” is equal to square root of “b”)arrow_forwardWrite a function called FindMyChar that receives three parameters: . the name of the array • the array size • a character ch The function must return the index number in which the character ch is in your array. If the character ch is not found of the array, insert ch in the last index of the array and return that index number. This index number will be printed from your main( ). For the toolbar, press ALT+F10 (PC) or ALT+FN+F10 (Mac). BIUS Paragraph Arial 14px A v ... Click Save and Submit to save and submit. Click Save All Answers to save all answers. Save All Answers Save and Submit 梦 $ 耳 a 911A S/19/20 hp 12 -> ort sc home delete nd %24 4. & 7. 6 8 num %3D backspace lock R Y. home 4. enter pause 1 shift end alt ctrlarrow_forwardThe purpose of this program is to write a series of function to manipulate a two-dimension array. ArrayData method: It will allocate a block of memory which represents a two-dimension array based on the input values supplied by the user. Ask the user to enter the number of rows and column for 2D array that the user want to manipulate. The number of rows and columns that the user enters may or may not define a square matrix (when the number of rows equals the number of columns). The array will have exactly rows time columns (m * n) elements. It will not contain any extra or empty cells. Initialize the “matrix” by rows with random number between 1 to 100. Pass two arguments by out reference so that you can assign the number of row and columns of data to the first and second arguments. This is return 2D array method after allocating new memory for 2D array and initialize it with random value. Generate random number code in C# as following: Random randnum = new Random( );…arrow_forward
- 1.Enter a positive integer value n (6 <= n < 30) and take n integers from the user as input and store them in array a. Then move the elements of this array one step to the left and make the first element of the array the last element of the array. Shift this array with a function. Display integer value n, the array elements in original order and the array elements in modified order (after shifting). For example, if the original order of the array a is like below : a: 33 45 67 89 12 7 After shifting one step to the left, you should get the following order of the array а: a: 45 67 89 12 7 33arrow_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_forwardusing 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_forward
- create 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 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_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_forwardI am trying to write a void function, called makeNewArray, that prints a string array in reverse, and each word in reverse. The makeNewArray function needs to call a previously made array called printArray. I am pasting it here for you to see it. There is also a reverseArray function that I need to call in the makeNewArray function. I am also posting that here. Please can you help??? Feel free to change any code that needs to be changed ... except the function names. void printArray(string a[], int dsize, ostream out) {for (int i = 0; i < dsize; i++){out << a[i] << " ";}out << endl;} void reverseArray(string s[], int dsize) {for(int i = 0; i < dsize / 2; i++){swap(s[i], s[dsize - i - 1]);}} void makeNewArray(string s[], int dsize, ofstream &fout) {fout << "Printing the string array:" << endl;for(int i = 0; i < dsize; i++){int beg = i;for(int j = dsize; j>=dsize; j--){if(s[j] < s[beg]){beg =…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