subject

Your colleague developed a function, which is supposed to reverse an array of integers, e. g., {1, 5, -10, 7, 23} => {23, 7, -10, 5, 1}. Test cases show that the function does not work correctly. Please look at the following code and identify all the troubles. Please specify which part(s) of the code will not work and explain why not. void ReverseArray(int arr[], size_t elements_no) {
size_t i = 0; int x = 0; for (i = 0; i <= elements_no; i++)
{ x = arr[i]; arr[i] = arr[elements_no - i]; arr[elements_no - i] = x; }

}

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 15:30
When creating a budget, log fixed expenses before income. after income. after savings. at the top.
Answers: 1
question
Computers and Technology, 23.06.2019 20:30
If an appliance consumes 500 w of power and is left on for 5 hours, how much energy is used over this time period? a. 2.5 kwh b. 25 kwh c. 250 kwh d. 2500 kwh
Answers: 1
question
Computers and Technology, 23.06.2019 21:00
Which task uses a simple parameter?
Answers: 1
question
Computers and Technology, 24.06.2019 19:50
Which is a characteristic of free and open-source software licenses? a. the source code is unavailable to everyone b. the source code is available only to the government c. the source code is available to all users d. the source code is constantly modified
Answers: 1
You know the right answer?
Your colleague developed a function, which is supposed to reverse an array of integers, e. g., {1, 5...
Questions
question
Mathematics, 12.01.2021 18:50
question
English, 12.01.2021 18:50
question
Mathematics, 12.01.2021 18:50
question
Physics, 12.01.2021 18:50
question
Mathematics, 12.01.2021 18:50
question
English, 12.01.2021 18:50
Questions on the website: 13722361