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); منم }
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 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
#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
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;
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 >...
Write the following expression as an algebraic expression. V3 tan where x > 0 V22 +
Uses Java
In this lab, you will practice using a stack as a substitute for recursion. Your task is to implement a non-recursive stack-based version of the following method: public void drawGasket(int x, int y, int side) t int sub -side / 3; //Draw center square g2d.fill (new Rectangle2D. Double(x + sub, y + sub, sub - 1, sub - 1)); if (sub >= 3) { //Draw 8 surrounding squares for (int i = 0; i < 3; i++){ for...
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