1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Ivahew [28]
3 years ago
14

5.8.1: Modify an array parameter. Write a function SwapArrayEnds() that swaps the first and last elements of the function's arra

y parameter. Ex: sortArray = {10, 20, 30, 40} becomes {40, 20, 30, 10}. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 #include using namespace std; /* Your solution goes here */ int main() { const int SORT_ARR_SIZE = 4; int sortArray[SORT_ARR_SIZE]; int i; int userNum; for (i = 0; i < SORT_ARR_SIZE; ++i) { cin >> userNum; sortArray[i] = userNum; } SwapArrayEnds(sortArray, SORT_ARR_SIZE); for (i = 0; i < SORT_ARR_SIZE; ++i) { cout << sortArray[i] << " "; } cout << endl; 1 test passed All tests passed Run

Computers and Technology
1 answer:
viktelen [127]3 years ago
3 0

Answer:

see explaination

Explanation:

#include<stdio.h>

/* Your solution goes here */

//Impllementation of SwapArrayEnds method

void SwapArrayEnds(int sortArray[],int SORT_ARR_SIZE){

//Declare tempVariable as integer type

int tempVariable;

if(SORT_ARR_SIZE > 1){

tempVariable = sortArray[0];

sortArray[0] = sortArray[SORT_ARR_SIZE-1];

sortArray[SORT_ARR_SIZE-1] = tempVariable;

}

}

int main(void) {

const int SORT_ARR_SIZE = 4;

int sortArray[SORT_ARR_SIZE];

int i = 0;

sortArray[0] = 10;

sortArray[1] = 20;

sortArray[2] = 30;

sortArray[3] = 40;

SwapArrayEnds(sortArray, SORT_ARR_SIZE);

for (i = 0; i < SORT_ARR_SIZE; ++i) {

printf("%d ", sortArray[i]);

}

printf("\n");

return 0;

}

Please go to attachment for the program screenshot and output

You might be interested in
What is a quick way to determine if a site might contain reliable information? looking at the title of the webpage reading the f
kvasek [131]

The answer is checking the URL.  

Looking at the URL or the web address of the website will help you determine  whether the site contains reliable and credible information or not. Domain names like .edu and .gov are usually trusted sites. What you are looking for are sites with trusted institutions that have a proven record of integrity and reliability. Domain type should always match the content. For example, .edu should have educational material.  By checking the URL, You’ll also be able to establish the person’s name or the agency that published the article.  


8 0
4 years ago
Read 2 more answers
The operating system provides a ____, which is the means with which you interact with the computer
Soloha48 [4]
One answer could be a GUI = Graphical User Interface (e.g. Windows Explorer).
4 0
4 years ago
Being nice take the points​
MArishka [77]

Answer:

Sure!!! and thank you very much

4 0
3 years ago
suppose as a head software engineer you assign the job of creating a class to a subordinate. You want to specify thirty-eight di
Goryan [66]

Answer:

jskjsjsjsjskdmsnjsnsnsns

8 0
3 years ago
In every programming language, when you access data stored in an array, you must use a ____ containing a value that accesses mem
Mariulka [41]
An array is an indexed collection of data elements. First you must declare an array, give its name and data. <span>Once your arrays are declared, you access the elements in an array with the array name, and the index number inside brackets [ ].
So, in every </span><span>programming language, when you access data stored in an array, you must use a command [] (brackets) containing a value that accesses memory occupied by the array.</span>
4 0
3 years ago
Other questions:
  • In the 1950s, the three major networks (ABC, NBC, and CBS) developed prime-time shows that would appeal to a general family audi
    11·1 answer
  • An existing document that you use as a starting point for a new document; it opens a copy of itself, unnamed, and then you use t
    15·1 answer
  • Write a function with two parameters, prefix (a string, using the string class from ) and levels (an unsigned integer). The func
    14·1 answer
  • What is encyclopedia. Com considered to be?
    14·1 answer
  • Which of the following statements is false? People tend to shortcut security procedures because the procedures are inconvenient.
    13·1 answer
  • Which type of server runs Active Directory?
    12·1 answer
  • Matlab In this assignment you will write a function that will calculate parallel resistance for up to 10 parallel resistors. Cal
    15·1 answer
  • Question 14. 14. PowerPoint assumes every new slide, except for a blank slide, has _____.
    13·1 answer
  • A(n) ________ software installation copies all the most commonly used files to your computer's hard drive.
    10·1 answer
  • The Quick Access tool bar allows you to customize the actions or commands you frequently use.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!