i =1 at first j =35
condition is j>0 and inside the loop we have the condition j=j/2. So everytime j gets divided by 2 and we check the condition
since it is integer division so result will also be integer .The values of j where condition j>0 is checked is
j=35,17,8,4,2,1,0
0 is included beacuse 0>0 is false but condition check is done .
So for i=1 there will be 7 evaluation of j>0.
Similarly for i=2,3
Now when i=4 the condition i<=3 is not satisfied so it breaks from the loop therefore total is 7+7+7=21.
Answer is none of the other answers are correct.
When the Java source code below is executed, how many times is the boolean expression (j...
Question 68 (Mandatory) (1 point) When the Java source code below is executed, how many times is the boolean expression (j > 0) evaluated? = int i 1; int p 0; while (i <= 2) for(int j = 28; (j > 0); j /= 2) { p+= 5; { } i i + 1; مه none of the other answers are correct 12 6 18
What is printed when the following code is executed? #include <stdio.h> int main() { for (int i=3, j=5; i>=0; i-=2, j+=j*i) { printf("%d", j); منم }
java by the way
What is the value of the variable y after the following code is executed? int x = 10; int y = 0; while (x > 0) { x = x / 2; y++; } 4 3 2 1
In the code given below, how many times the cout statement is executed? for (int x = 0; x< 10; x++) for (int y=0; y < 10; y++) for (int z = 0; z <=10; z++) cout << X+y+z;
14.3 How many times is the statement cout<<]<<","<</<<","; executed in the following program? int I, ); for (I = 2; I >= 0; I--) { for (] = 1; }<2; J++) cout << ) << ", << I << cout << endl; 11 } Select one O 2.3 0 6.6 O c. 2 d. None of the above are correct
Java code efficiency: Look at the implementation of the method called intervalSums below. Design and implement a more efficient runtime algorithm for intervalSums. public static long intervalSums(intll A, intl0 B) long count = 0; for (int i = 0; i < A.|ength; i++) { for (int j = i; j < A.length; j++) { int sum = 0; for (int k = i; k <= j; k++) { sum += A[k]; count += 1; B[i][j] = sum; if (j >...
#include<stdio.h> eint main() { int i = 0, j = 0; while (i < 10|| j < 7) { i++; j++; } printf("%d, %d\n", i, j); getchar(); return 0; } 01,01 10,10 7.7 10,7
Pseudocode to code in java
. Pseudocode: ARRAY a e..n] . min = 0 · max = n WHILE (max > min) (j = min . .max) IF FOR (a[j] 〈 a[min]) swap(a, j, min) END-IF IF (a[j] 〉 a[max ] ) swap(a, j, max) END-IF END- FOR min min + 1 max = max-1 END-WHILE
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
Please answer the above queston (in terms of C programming) and
explain answer
Semester 2 & Trimester 3B, 2015 COMP1004 Engineering Programming Question 3 - Repetition (20 marks) Q3(a) What will be printed when the following code is executed? (5 marks] #include <stdio.h> int main() int i, j; for(i=1;i<17;i=i+2) { printf("%d==", i); for(j=i; j>0;j--) printf("#"); printf("\n"); return 0; == # 3 = = # # # 5 == ### ## 7 #### #