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
Write a function shampoo_instructions() with parameter num_cycles. If num_cycles is less than 1, print "Too few.". If more than
Mama L [17]

Answer:

def shampoo_instructions(num_cycles):

   #Check the cycles to be greater than 1.

   if num_cycles < 1:

     

       #Display the statement.

       print('Too few.')

     

   #Check the cycles to be greater than 4.

   elif num_cycles > 4:

     

       #Display the statement.

       print('Too many.')

     

   #The else part.

   else:

     

       #Initialize the variable.

       N = 1;

         

       #Begin the for loop.

       for N in range(N, num_cycles+1):

         

           #Print the result.

           print(N , ": Lather and rinse.")

         

       #Print the statement.

       print('Done.')

#Call the function.

shampoo_instructions(2)

Explanation:

7 0
3 years ago
Which part of the cpu holds the memory address for the next instruction to be processed?
aleksley [76]
Register, google CPU registers for more info
7 0
4 years ago
15. Virus cannot infect files that are saved in i. USB ii. CD-ROMs iii. Memory card iv. All of them​
kramer

Answer:

all of them

Explanation:

but Virus can infect them if u plug them in infected computer .

7 0
3 years ago
Read 2 more answers
25-words or more in your OWN words the meaning of digital literacy.
jolli1 [7]

Answer:

Digital literacy means having the skills you need to live, learn, and work in a society where communication and access to information are increasingly through digital technologies like internet platforms, social media, and mobile devices.

Explanation:

6 0
3 years ago
State the difference between IBM PC and apple machintosh computers
azamat

Answer:

a Mac is a PC because PC stands for personal computer. However, in everyday use, the term PC typically refers to a computer running the Windows operating system, not the operating system made by Apple.

7 0
3 years ago
Other questions:
  • One of the essential skills that software development engineers must have is the proficiency in at least one of the modern compu
    6·1 answer
  • Which of the following resulted in a rightward shift in supply?
    5·1 answer
  • If a business owner wanted to create a banner ad for his business on his webpage, he could use Java programming to develop a (n)
    7·2 answers
  • Which best describes what Pavel should do differently for the kids book?
    13·2 answers
  • Once you record your audio and click ok to save it what happens to the recording?
    9·1 answer
  • A RAID structure ____. is primarily used for security reasons is primarily used to ensure higher data reliability stands for red
    14·1 answer
  • Active space is important in which type of photograph?
    12·2 answers
  • Windows 8 has a built-in antivirus program called
    10·1 answer
  • Why people shouldnt get married​
    6·1 answer
  • Select the data type for each example below. <br> Possible answers<br> -Int<br> -float <br> -string
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!