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:30
Janeโ€™s team is using the v-shaped model for their project. during the high-level design phase of the project, testers perform integration testing. what is the purpose of an integration test plan in the v-model of development? a. checks if the team has gathered all the requirements b. checks how the product interacts with external systems c. checks the flow of data in internal modules d. checks how the product works from the client side
Answers: 1
question
Computers and Technology, 22.06.2019 23:50
You need to design a circuit that implements the functions in the following table: s0 s1 function0 0 a + 10 1 a โ€“ b1 0 a + b1 1 a โ€“ 1s0 and s1 are 1-bit control inputs to select the function of the circuit. inputs a and b are 4-bitnumbers in 2s complement form. the output is also a 4-bit number in 2s complement form.you are allowed to use only one ttl 7483 4-bit adder to implement all the functions. but anynumber of other components (except the adder) can be used.hint: design a combinational logic circuit to modify the input b and the โ€œcarry inputโ€ of theadder depending on the control inputs s0 and s1.important: lab grade will depend on the working of the circuit & will be checked of by your labinstructor.1. is the output valid for the following input combinations: a. s0 = 0, s1 = 0, a = 7, b = 3? b. s0 = 0, s1 = 1, a = 7, b = 3? c. s0 = 1, s1 = 0, a = -4, b = -5? d. s0 = 1, s1 = 1, a = -8, b = 6? 2. what is the range of inputs (for both a and b) that will produce the valid output for all the functions?
Answers: 3
question
Computers and Technology, 23.06.2019 23:00
Computer programming is one type of what career
Answers: 1
question
Computers and Technology, 25.06.2019 04:30
You can fit more raw files on a memory card than the jpeg files? truefalse
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
Advanced Placement (AP), 30.01.2021 02:20
question
Biology, 30.01.2021 02:20
question
Mathematics, 30.01.2021 02:20
question
Mathematics, 30.01.2021 02:20
Questions on the website: 13722363