subject

Suppose a program is supposed to reverse an array. For example, if we have the array arr = {1, 2, 3, 4, 5}, after reversing the array we would have arr = {5, 4, 3, 2, 1}. Most of the code for the program is shown here:
Const int SIZE = 5;
int arr[SIZE] = {1, 2, 3, 4, 5};
int firstindex =0, lastindex = SIZE-1, temp;

1

{
temp = arr[firstindex];
arr[firstindex] = arr[lastindex];
arr[lastindex] = temp;
firstindex++;
lastindex--;
}

All of the following options below could be correctly inserted at line 1 in the code shown above EXCEPT:

a. while(firstindex < lastindex)
b. while(firstindex <= lastindex)
c. for(int i=0; i<(SIZE/2-1); i++)
d. for(int i=0; i<(SIZE/2); i++)

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 13:00
Which option should u select to ignore all tracked changes in a document
Answers: 1
question
Computers and Technology, 23.06.2019 20:30
What are some settings you can control when formatting columns?
Answers: 1
question
Computers and Technology, 24.06.2019 15:00
In excel, what happens to the cell contents when you click and drag a cell into multiple cells?
Answers: 1
question
Computers and Technology, 24.06.2019 23:00
What is a current gdp and what is a real gdp?
Answers: 1
You know the right answer?
Suppose a program is supposed to reverse an array. For example, if we have the array arr = {1, 2, 3,...
Questions
question
Biology, 16.11.2020 23:40
question
Mathematics, 16.11.2020 23:40
question
World Languages, 16.11.2020 23:40
question
Mathematics, 16.11.2020 23:40
question
Mathematics, 16.11.2020 23:40
question
Chemistry, 16.11.2020 23:40
Questions on the website: 13722363