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
Law Incorporation [45]
3 years ago
8

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)
#include
/* Your solution goes here
*/ int main(void) {
const int SORT_ARR_SIZE = 4;
int sortArray[SORT_ARR_SIZE];
int i;
int userNum;
for (i = 0; i < SORT_ARR_SIZE; ++i) {
scanf("%d", &sortArray[i]);
}
SwapArrayEnds(sortArray, SORT_ARR_SIZE);
for (i = 0; i < SORT_ARR_SIZE; ++i) {
printf("%d ", sortArray[i]);
}

Computers and Technology
1 answer:
sergey [27]3 years ago
4 0

Answer:

Here is the SwapArrayEnds()

//function with two parameters; the array and array size

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

int temp;   //temporary variable to hold the first element of sortArray

if(SORT_ARR_SIZE > 1){   //if sortArray size is greater than 1

temp = sortArray[0];   // set value of temp to the first element of sortArrray

sortArray[0] = sortArray[SORT_ARR_SIZE-1];   // set the value of first element of sortArray to the last element of sortArray

sortArray[SORT_ARR_SIZE-1] = temp;  }  } // set last element  value to temp

Explanation:

Lets understand the working of the above function with the help of an example. Suppose the sortArray has the following elements: {10,20,30,40}. So the size of this array is 4.

if(SORT_ARR_SIZE > 1) has an if statement which checks if the array size is greater than 1. This condition evaluates to true as 4 > 1. So the body of if condition executes.

Next the statement temp = sortArray[0];   sets the value of temp variable to the value of first element of sortArray. As sortArray[0] means the element at 0-th index position of the sortArray. So using the above example the first element of the array is 10. So temp = 10.

Next the statement sortArray[0] = sortArray[SORT_ARR_SIZE-1];   sets the last element of the sortArray to the position of first element of the sortArray.

SORT_ARR_SIZE-1 is the position of last element of the array. As the size of sortArray is 4, so 4-1 = 3 which points to the last element. Now this element is moved to the first position of the array. This means that the value of first element of array becomes 40 as the element at 3-th index of the sortArray is 40.

Next the statement sortArray[SORT_ARR_SIZE-1] = temp moves the value in temp variable to the last position of the sortArray. As we know that the value of temp= 10. So this element 10 of the sortArray is positioned at SORT_ARR_SIZE-1 position of sortArray which is 4-1 = 3-th index of sortArray. This simply means that 10 is moved to the last position of sortArray.

So now the final sortArray becomes: 40,20,30,10 as the first and last element of the array are swapped using above function SwapArrayEnds().

The program along with the output is attached in screenshot.

You might be interested in
An application server is used to communicate between a Web server and an organization's back-end systems.
seropon [69]
Yes but i dont think theres a representative behind the same question ur on
7 0
3 years ago
1.What is a project methodology?
blagie [28]

Explanation:

1. Let’s suppose that we want to test a scientific hypothesis. What we need to do first is to come up with steps and techniques for testing this hypothesis. This, in a similar way explains what project methodologies are. A project methodology gives us a properly organized way of planning and executing a substantial amount of work that needs to be completed in a given amount of time. Think of it as a game plan that you need to up with to develop a product or an IS.

2. Following a particular methodology comes with its own advantages.

  1. 1. It gets you focused on the product you are trying to come up with.
  2. 2. So many lessons will be learnt and will be documented as experiences and will be integrated as best practice. In the event that the project is a success, the same methodology can be used once again in the future.
  3. 3. Saves time since the same prescription of tools, phases, and techniques used for a particular project can be reused once more to come up with another project.

3. It maps out the existence of a project from start to finish. It is defined within a given methodology. Projects, like humans, have defined life-cycles. The same way we come out of wombs, grow, mature, decline, and then die is the same way a project has a beginning, mid, and end.

4. It does not matter whether a project one is working on is huge or not, they have to be organized into a sequence of phases for manageability. These phases include phase exits, stage gates, and kill points. Having these phases aligned together will give an organization a clear indication of how to evaluate the project’s performance and be able to mitigate problems that arise.

5. Starting the next phase just before the current one ends can sometimes be a good thing since it can reduce the schedule of the project. This is what is known as fast tracking. It is a good idea but introducing one phase before another one ends can cause an overlap and as a result can pose as a risk. Do it if the risks are within scope and can be accepted.

6. An idea that someone comes up with to build a new information system or product can be counted as one of the initiation processes of a PLC.  However, the first process is to define the goal of the project. Organizations have put amounts of time and investments into coming up with a project. Therefore, every little aspect of the project should be properly envisioned to meet the business's value. This is phase where we should ask ourselves questions like whether the project is going to be successful and how we will identify its success in correlation to the investments raised by the stakeholders. It is the phase upon which every detail is looked into carefully and goals defined before the project is flagged off.  

7. This phase provides the direction and planning for the project. Once the project has been flagged off and is ready to move forward, the team needs to define what the objectives will be, when and what time the project will be completed, and the amount of money that will be required to finish. In addition, things like how many people are we looking at to complete the project and the technology that will be used to build the project are highly considered and looked into in this phase.

8. At this point, the project must be approved first before moving on to this phase. The teams put all efforts of design, development, and delivery of the final product. Whoever has invested on the product will now start to have a clear picture of everything that is going on from the first phase of planning to the actual implementation based on time it has taken to the budget that has been so far.

9. Every beginning must always have an end and this is the phase that ensures a well-defined end. It ensures that the amount of effort and work that the teams have put in developing and implementing the product is complete. This phase also sees the team and stakeholders have meetings to try and consolidate and come into terms of whether or not the goals of the planning phase have been achieved.

10. Because every single project has its own goals and achievements that it wants to meet. Every product is unique in terms of what it wants to achieve and the principles and practices might not work for every project. It is the processes used to come up with the particular project that will play an integral part in the life cycle

Learn more about project methodologies by clicking on the link below

brainly.com/question/13821095

brainly.com/question/988326

#LearnWithBrainly

4 0
3 years ago
Complete the sentence with the correct response. In a two-way selection, if the initial statement is evaluated as , the code ski
mestny [16]

Answer:

True.

The code skips the else command

Explanation:

I will answer this question with the following code segment

<em>n = 1</em>

<em>If n > 0:</em>

<em>   Print("greater than 0")</em>

<em>else:</em>

<em>   Print("not greater than 0")</em>

<em />

From the code segment above

<em>Print("greater than 0")</em> will be executed because the condition <em>If n > 0 </em>is true

Since the if condition is true, the else condition will not be executed

8 0
3 years ago
Describe how a user would interact with a smart-phone to do various tasks.Consider inputs and outputs.
xz_007 [3.2K]

A smart-phone is also referred to as a mobile device and it can be defined as a small, portable, programmable-electronic device that is designed and developed for sending (transmission) and receiving data (messages) over a network. Thus, a smart-phone must be designed as a hand-held device with communication capabilities.

Basically, the components that make up a smart-phone can be classified into two (2) main categories and these include:

1. <u>Input:</u> it comprises mouthpiece, keyboard, light sensor, etc.

2. <u>Output:</u> it comprises screen, speaker, earpiece, etc.

In this context, an end user would interact with a smart-phone in the following ways to perform (do) various tasks:

  • By using a keyboard to type a text and then sending it to another person.
  • By using a mouthpiece as an input for voice (audio) messages when making call.
  • The screen of a smart-phone displays the necessary information to an end user.
  • When playing a digital music file the speaker produces the output as sound.

Read more on smart-phone here: brainly.com/question/4922532

7 0
3 years ago
If a person sends email from a school computer or a business computer, should that message be considered private?
mars1129 [50]

Answer:

yes

Explanation:

6 0
3 years ago
Read 2 more answers
Other questions:
  • Which of the following is true about the strategy that uses page fault frequency (PFF) to prevent thrashing?
    6·2 answers
  • One particularly effective form of providing feedback is for the receiver to ________. restate the message in his or her own wor
    14·1 answer
  • Object-oriented development could potentially reduce the time and cost of writing software because: Group of answer choices a) i
    5·1 answer
  • Where would you look to see how much space is available on your c drive?
    8·1 answer
  • WHAT DOES THE WORD MONOCHROME MEAN?
    11·1 answer
  • The engine flywheel bolts to the Rotor Pistons Front axle Crankshaft
    13·1 answer
  • Can someone solve this for me please? It’s part of an escape room.
    13·2 answers
  • They are correct? thank you!
    5·1 answer
  • Plsssssssss help me​
    8·1 answer
  • You suspect that a bad video driver is causing a user's system to randomly crash and reboot. Where would you go to identify and
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!