1 int i, j, k;
2 for (i = 1; i <= 4; i++)
3 {
4 j = 1;
5 while (j < 4)
6 {
7 if (i % 2 == j % 2)
8 k = 100*i + 10*j;
9 else
10 k = 100*j + 10*i;
11 j++;
12 }
13 }
What will be the value of the variable k at the end of the third, sixth, ninth, and twelfth iteration of the while loop
****************************************************************************************** Please Upvote the answer as it matters to me a lot :) ***************************************************************************************** As per HomeworkLib expert answering guidelines,Experts are supposed to answer only certain number of questions/sub-parts in a post.Please raise the remaining as a new question as per HomeworkLib guidelines. ****************************************************************************************** In iteration 1 the value of i is 1 j is 1 and the value of k is 110 In iteration 2 the value of i is 1 j is 2 and the value of k is 210 In iteration 3 the value of i is 1 j is 3 and the value of k is 130 In iteration 4 the value of i is 2 j is 1 and the value of k is 120 In iteration 5 the value of i is 2 j is 2 and the value of k is 220 In iteration 6 the value of i is 2 j is 3 and the value of k is 320 In iteration 7 the value of i is 3 j is 1 and the value of k is 310 In iteration 8 the value of i is 3 j is 2 and the value of k is 230 In iteration 9 the value of i is 3 j is 3 and the value of k is 330 In iteration 10 the value of i is 4 j is 1 and the value of k is 140 In iteration 11 the value of i is 4 j is 2 and the value of k is 420 In iteration 12 the value of i is 4 j is 3 and the value of k is 340
Sample Code I int j = 3; int k = j; if (k > 22) break 7 9 while (k 21); 10 System. out.print (k>; Referring to the sample code above, what is the value of variable k on line 10? 20 Question Choice 1 Choice 2 Choice 3 21 23 Choice 4 Choice 5
How to prove G(n)=n+1 in this algorithm? 1. if (n 0) 2. return 1 3. else if (n1) f 4. return 2 5. else if (n 2) 6. return 3 7. else if (n3) t 8. return 4 else f 9. int OGnew int[n 11 10. G[O]1 12. G[2]3 13. G[3]4 14. int i:-4 15. while (i<n) t 16. if (i mod 20) else ( 20. return G[n] 1. if (n 0) 2. return 1 3. else if (n1) f...
How many Iterations will this while loop perform? int ico), j(10); cout << "i = " << i << endl; cout << "j = " << j << endl; while (i > j) { cout << "j-" « j << endl; j += 2; cout << "i = " << i << endl; } cout << "i = << i << endl; cout << "j = " << j << endl; 5 6 C 8 10 Infinite times Does the...
Convert the following to mips assembly: int recursion (int N) { int i, j, k; if (N greater than 9) { print "End recursion\n"; return N; } print "Recursion in "; print N; print ":"; for (k=0; k less than N; k=k+1) print "x"; print "\n"; i = N + 7; j = N + 1; k = 13 - i; j = recursion (j); j = j - k; j = j + i; print "Recursion...
Consider the following code segment. int[]arr={1, 2, 3, 4, 5, 6, 7, 8}; for(int k=3; k<arr.length-1; R++ arr[k]-arr[k+1]; What are the contents of arr as a result of executing the code segment? a. {1, 2, 3, 5, 6, 7, 8, 8) b. {2, 2, 4, 5, 6, 7, 8, 8} C. {2, 4, 6, 5, 6, 7, 8,8} d. {4, 2, 4, 4, 6, 7, 8, 8) e. {6, 6, 4, 5, 6, 7, 8, 8} int) arr={7, 2.5, 3.0,...
Prove procedure to compute Fibinocci(n) where F0 = 0, F1 = 1, Fn = Fn-2 + Fn-1. Prove by establishing and proving loop invariant then using induction to prove soundness and termination. 1: Procedure Fib(n) 2: i←0,j←1,k←1,m←n 3: while m ≥ 3 do 4: m←m−3 5: i←j+k 6: j←i+k 7: k←i+j 8: if m = 0 then 9: return i 10: else if m = 1 then 11: return j 12: else 13. return k
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...
please fill the tables We were unable to transcribe this imageWhat kind of Loop Structure is this? iterations evals Notes 16a-int (inputO) 17 b a Step Statement 18 for x in range(a 3, a5, 2): 2 20 21 else: 23 24 print(b) 4 5 6 8 9 10 12 13 What kind of Loop Structure is this? Step Statement Notes iterations evals 18 19 20 21 iteration-0 evals-0 print("Boolean evaluation #:", evals) prin "Iteration #:", iteration! 23 evals1 24 while...
I must execute in C using parallel Programming techniques the following serial program: void producer_consumer(int *buffer, int size, int *vec, int n) { int i, j; long long unsigned int sum = 0; for(i=0;i<n;i++) { if(i % 2 == 0) { // PRODUCER for(j=0;j<size;j++) { buffer[j] = vec[i] + j*vec[i+1]; } } else { // CONSUMER for(j=0;j<size;j++) {...
I posted this question earlier but realized that the code was not easy to test since it was just screenshots and not text so I am reposting it: I'm very new at working with file streams, and I'm having trouble with a HW assignment I have to work on. For the assignment I have to read an input file named "MagicSquaresIn.txt" (included at the bottom) and I have to check whether they are normal, associative, and panmagic. To check that...