Computers and Technology
24.12.2020 06:42
130
338
9
Solved by an expert

Langauge: C++Make absolutely no changes to main(). Change function backwards so

Langauge: C++Make absolutely no changes to main(). Change function backwards so that the elements of the array are swapped in order for elements to be in reverse order. That is, arr[0] will be 16, arr[1] will be 5, etc. But backwards() must work no matter what values are in the array and for all values passed in for number. After it is corrected this program should output:16531782#include using namespace std;void backwards(int [], int);int main(){int arr[] = {2,8,17,3,5,16}; int i;backwards(arr,6);for (i = 0; i< 6; i++)cout<
Show Answers
grayfaith16
grayfaith16
4,5(13 marks)

#include <iostream>

using namespace std;

void backwards(int [], int);

int main()

{

int arr[] = {2,8,17,3,5,16}; int i;

backwards(arr,6);

for (i = 0; i< 6; i++)

cout<<arr[i]<<endl;

//system("pause");

return 0;

}

void backwards(int array[], int number)

{

/*Pre: array[] - array of integers

number - number of elements in the array that have values

Post: Nothing

Purpose: Reverse the order of the elements of an array */

int i; int temp;int j;

for(i = 0; i < number;i++)

{

temp = array[i];

array[i] = array[number - 1 - i];

array[number - 1 - i]=temp; // Just change is needed here, the assignment was wrong rest all is ok.

}

return;

}

vicada2782
vicada2782
4,9(18 marks)

o

Popular Questions about the subject: Computers and Technology

An employee is setting up an outlook email account and calls the desk asking...
Computers and Technology
15.04.2022 21:48
Assignment write the html code to generate a web page in the format specified...
Computers and Technology
21.08.2021 19:54
4. find find an equation in slope-intercept form for the line through point...
Computers and Technology
08.08.2021 03:29
Secure shell (ssh) operates over which port by default...
Computers and Technology
07.08.2021 22:37
Your computer running windows 10 is doing some very strange things with the...
Computers and Technology
08.10.2020 22:34
The internet began when a large company wanted to sell products online. true...
Computers and Technology
19.08.2022 03:38
Is there any safe website where it checks my grammar and check if u did a good...
Computers and Technology
11.08.2022 20:33
Which structure does a web page normally use to define an area of focus?...
Computers and Technology
12.06.2021 09:10
The binary search algorithm: (a) is less efficient than the sequential search...
Computers and Technology
21.07.2021 22:28
The person charged with actually planning and implementing the change necessary...
Computers and Technology
08.02.2023 03:06

New questions by subject

Directions: Analyze each statement by writing the word TRUE if the statement...
Social Studies
27.02.2021 23:40
Every individual is continually exerting himself to find out the most advantageous...
Geography
06.07.2020 23:20
Five Biomedical Importance of Nucleotides...
Chemistry
23.09.2020 11:48
Rewrite the following mathematical expressions as corresponding C statements....
Engineering
14.10.2020 10:27
Using different examples clearly explain the difference of power and authority...
Business
29.02.2020 03:25
Helpp I need help now please...
English
19.10.2022 14:08
Write the answer for each statement given: 1.The scientific name of your jawbone...
English
09.04.2020 04:19
Przyjrzyj się kolejnym etapom obliczeń....
Mathematics
18.05.2022 00:26
Why pushing a box up a hill is harder than pushing it on flat ground?...
Physics
19.03.2023 00:57
#
#
#
#
# #

We expand our knowledge with many expert answers