16. Insert the missing line of code so that the following adds the integers from 1 to 10, inclusive.
value = 0
top = 10
score = 1
while score <= top:
value = value + score
#the missing line 1
7. What is the output after the following code is executed?
16). missing line is score=score+1
Because the code is adding numbers from 1 to 10. So we need to increase the value of score in while loop such that it will give correct values to 'value' variable. When score value is greater than 10,then while loop exits because score<=top will become false.
Answer:- score=score+1
17). The output of the following code is
1 20 2 19 3 18 4 17 5 16 6 15 7 14 8 13 9 12 10 11.
low value is increasing by 1 and simultaneously high is decreased by 1. So its printing the above output.
Insert the missing line of code so that the following adds the integers from 1 to 10, inclusive.
Write a C++ program with the following functionality. Place the even integers from 10 (inclusive) to 40 (inclusive) in a queue, Q. Remove the first 10 integers from Q and add to a stack, S. Pop and print all the elements from S.
: (6 points) Typical hash function for a string key. Fill the missing line of code. Th hash function should compute a polynomial of the form: s[0] + s[1] * 37 + s[2] * 372 + s[3] * 373 + + s[n-l] * 37", where s[i] is the it character of string s, for i = 0, . . ., n-1. The length of string s is n. si size_t hash(const string &s) 1f const int n- s.length); for (int...
A stack S of integers initially contains the following data: 6 (top) 2 7 3 The following code is then executed: int x = S.pop(); int y = S.pop(); int z = S.pop(); S.push(x + y); int w = S.pop(); S.push(w + z); After this code has been executed, what are the contents of the stack? A. 8 10 B. 10 8 C. 15 3 D. 10 8 6 3
Write a program that asks the user to input 10 integers of an array. The program then inserts a new value at position (or index) given by the user, shifting each element right and dropping off the last element. For example, in the sample input/output below, the program will insert the value 30 at index 3. All the previous numbers of the array starting from position 3 (i.e., 7 1 20 9 23 8 22 will be shifted one position...
1. Write an INSERT statement that adds this row to the Categories table: CategoryName: Brass Code the INSERT statement so SQL Server automatically generates the value for the CategoryID column. 2. Write an UPDATE statement that modifies the row you just added to the Categories table. This statement should change the Category Name column to “Woodwinds”, and it should use the CategoryID column to identify the row. 3.Write an INSERT statement that adds this row to the Products table: ProductID:...
Question 16 What is the value of x after the following code is executed? X = 7 If x < 7 X = x + 1 X = x + 2 7 9 10 8
Write a program that first gets a list of integers from the input and adds them to an array. The input begins with an integer indicating the number of integers that follow (Your program should work for any size of the array). Then, get the last value from the input, and output all integers less than or equal to that value by iterating through the array. Ex: If the input is: Enter the number of integers: 5 Enter integer 1:...
2. What is the value of x alter the following code is executed # include<iostream> using namespace std; int main int t-0, c- 0,x-3; while (c < 4) t=t+x; cout << x return 0; a) 3 b) 21 c) 24 d) 48 3. What is the output of the following code? # include<iostream> using namespace std; int main0 int a- 3; for (int i 5; i >0; i) a a+i cout << a << “ “ return 0; d) 8...
Consider the following lines of Matlab code 1 arr-14,7.2,5,1,6: 2 for j 2:length(arr) 3 key arr) 4 i j-1; 5 while i - 1 && arr)> key 6 arr(+1) arr(); 8 end %end of while loop 9 arr(+1) key 10 end %end of for loop After line 8 gets executed the first time, the state of the array arr is. arr [4, 7, 7, 5, 1, 6] What is the state of the array arr after line 8 is executed...
Consider the following code segment, which is intended to store the sum of all multiples of 10 between 10 and 100, inclusive (10 + 20 + ... + 100), in the variable total. int x = 100; int total = 0; while( /* missing code */ ) { total = total + x; x = x - 10; } Which of the following can be used as a replacement for /* missing code */ so that the code segment works as...