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
Nadusha1986 [10]
3 years ago
7

Write a function SwapArrayEnds() that swaps the first and last elements of the function's array parameter. Ex: sortArray = {10,

20, 30, 40} becomes {40, 20, 30, 10}. The array's size may differ from 4.
#include
using namespace std;
/* Your solution goes here */
int main() {
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) {
cout << sortArray[i] << " ";
}
cout << endl;
return 0;
}.
Computers and Technology
1 answer:
ludmilkaskok [199]3 years ago
3 0

Answer:

Replace /* Your solution goes here*/ with the following

<em>void SwapArrayEnds(int sortArray [], int lent){ </em>

<em>    int temp = sortArray[0]; </em>

<em>    sortArray[0] = sortArray[lent-1]; </em>

<em>    sortArray[lent-1] = temp; </em>

<em>} </em>

<em />

Explanation:

This defines the function SwapArrayEnds with two parameter (the array and the array length)

<em>void SwapArrayEnds(int sortArray [], int lent){ </em>

This declares an integer variable "temp" and initializes it with the first element of the array

<em>    int temp = sortArray[0]; </em>

The next two lines swap the last element with the first

<em>    sortArray[0] = sortArray[lent-1]; </em>

<em>    sortArray[lent-1] = temp; </em>

<em>} </em>

<em />

<em>See attachment for full program</em>

Download cpp
You might be interested in
Discuss three ways you could (or currently do) use the Excel software in your personal or professional life. Provide examples an
professor190 [17]
Both in my personal and professional life, I use the Excel software in order to create tables and lists. It's much easier to do that in Excel rather than in Word, for example, because Excel was actually created for that purpose, whereas Word was created for writing, above all. I use Excel for work to create tables of various things, such as names, emails, payments, etc. whereas I use it in my personal life to create lists of things such as movies, books, etc.
3 0
3 years ago
Explain test-driven development and provide an example of how it can be used in your
dalvyx [7]

Answer:

 The test- driven development is basically use in the programming language for the designing various type of test cases in the computer system. The main goal of the test driven development is that it uses to make the system bug free and simple.

It basically use in the organization to avoid various duplication in the code and make the function more efficient.

The basic approach of the test driven development is that the test are develop so that it specify the function for the code to perform.

8 0
4 years ago
Rachel should use the feature in a word processing program to find typographical errors. She should apply to have uniform headin
Kay [80]
Yes that is a good starter
5 0
3 years ago
What is the difference between HTML and C?
Dmitry_Shevchenko [17]

Answer:

B

Explanation:

HTML is interpreted in web browsers, while C is complied and is low level, which is why many operating systems, including Linux use it.

I'm a programmer :)

3 0
3 years ago
Humor should never be used in a presentation as it will distract your audience.
Virty [35]
False, humor can be used to do many things including easing the audience into relaxation and trust.
8 0
3 years ago
Read 2 more answers
Other questions:
  • Refer to the exhibit. A network administrator configures a named ACL on the router. Why is there no output displayed when the sh
    7·1 answer
  • The state department that issues driver's licenses would like a police officer to be able to scan the driver's license and insta
    12·1 answer
  • Which is the correct formula to add the values in cells A1 and B1? A. SUM(A1+B1) B. =SUM(A1+B1) C. =SUMA1+B1 D. A1+B1
    9·2 answers
  • What are the keys in all rows that sit between the touch keys
    11·1 answer
  • Which of the following is something you need to keep an eye out for
    7·2 answers
  • Which operating system became obsolete with the arrival of more advanced graphical user interfaces
    12·1 answer
  • PLS HURRY!!<br> Look at the image below!
    7·1 answer
  • Surrendering to digital distractions can result in a disappointed
    9·2 answers
  • Which work habits should you follow to increase work efficiency and avoid health issues?
    6·1 answer
  • Capgemini
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!