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
What can be changed when a style is modified?
Gwar [14]

Answer:

Font

no hate If I'm wrong :)

3 0
3 years ago
Read 2 more answers
WILL MARK BRAIN LIST!
Maslowich
I think it’s a

if it isn’t a then it’s d
6 0
3 years ago
Read 2 more answers
Imagine that you are designing an application where you need to perform the operations Insert, DeleteMaximum, and Delete Minimum
fiasKO [112]

Answer:

A stack data structure should be used. The time complexity of the insert, delete minimum and maximum operation is O(1).

Explanation:

The stack data structure is an indexed structure that holds data in an easily retrievable way. Data is held in a first-in last-out method as elements in the structure are popped out from the end of the stack when retrieved sequentially.

The worst-case time complexity of getting the minimum and maximum elements in a stack and deleting it is O(1), this is also true for inserting elements in the stack data structure.

3 0
3 years ago
Select all the correct answers. Which two statements are true about an OS? translates the user's instructions into binary to get
lubasha [3.4K]

Answer:

all

Explanation:

4 0
4 years ago
Which key retains its uniqueness even after you remove some of the fields?
Natasha_Volkova [10]

Answer:

Primary key retains its uniqueness even after you remove some of the fields.

Explanation:

I am assuming that this question is related to database. Therefore, I am answering it according to database context.

In database, you can have multiple rows and columns. Each column shows a specific attribute while each row plots the data according to the attributes. However, there is the first column of each of main table that has unique set of values. It is called the Primary Key. Some key features of primary key are:

  • It always contains the unique value.
  • Its value cannot be null.
  • A table can have at max one primary key.
  • It can be the combination of multiple columns but it must be unique.

Therefore, the primary key has the ability to retain its uniqueness even after you remove some of the fields.

8 0
4 years ago
Other questions:
  • which resource do programmers sometimes have to refer to and use during planning the logical steps of the solution
    15·2 answers
  • Select all examples of good keyboarding technique.
    13·2 answers
  • Write a Python program that will take as input 5 integer values and will output the average of the odd values and the average of
    6·1 answer
  • What is the purpose of an exhaust emission system
    6·1 answer
  • Write 2-3 lines about the Basic operations of computer
    5·1 answer
  • A user complains that her computer is performing slowly. She tells you the problem started about a week ago when new database so
    12·1 answer
  • In dynamic programming, the technique of storing the previously calculated values is called A. Saving value property B. Storing
    7·1 answer
  • Determine the number of character comparisons made by the brute-force algorithm in searching for the pattern GANDHI in the text
    7·1 answer
  • What is a graphics card?
    5·1 answer
  • 1. While researching online, you come across an article that prominently displays the author's name. This source is likely to ha
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!