Given the following while loop, what is the value assigned to variable z for the given values of variables a, b and c?
mult = 0;
while (a < 10) { mult = b * a; if (mult > c) {
break;
}
a = a + 1;
}
z = a;
a = 4, b = 5, c = 20

a, b, c = 4, 5, 20
mult = 0;
while (a < 10) {
mult = b * a;
if (mult > c) {
break;
}
a = a + 1;
}
z = a;
iteration 1:
-------------
mult = 5*4 = 20
mult > c => 20 > 20 is false. so, loop will not break
a = a+1 = 4+1 = 5
iteration 2:
-------------
mult = 5*5 = 25
mult > c => 25 > 20 is true. so, the loop will break.
so, final value of a after the loop ends is 5. hence the variable z is set a value of 5.
Answer: 5
Given the following while loop, what is the value assigned to variable z for the given...
11) 16 pts. Convert the following for loop to a while loop. (You may want to do the following question first.) int mine [5] = {10, 11, 12); for (int j=1; j < 5; j++) cout <<j<< "" << mine[jl <<" " << end1; 12) 6 pts. What is the output of the previous question? 13) 4 pts. Circle the variables that would NOT cause syntax errors 2-smaTT , entry# break -my-int
2. What is the output of the following code fragment? n = 1; while (n <= 5) { n++; cout << n << ' '; a.1 2 3 4 5 b. 1 2 3 4 c. 1 1 1 forever d. 2 3 4 5 e. 2 3 4 5 6 3. What is the termination condition for the following While loop? while (beta > 0 && beta < 10) { cout << beta << endl; cin >> beta; }...
C++
help! #4,6,7
c) no-test d) loop-test e) None of these 1. Which of the following variable names is invalid? a) numstudents b) 2Darray c) studentHame d) test Grade 祁.which of the following conditions is true ifX has a value of 10 and T has a value of 20? None of these 2. In Ca4, the operator indicates: a) subtraction b) negation c) equality e) None of these . What are the final values of z and y after the...
A) Rewrite the following pseudocode segment in C++ using the loop structures (for and while). Assume that all the variables are declared and initialized. k-G+ 13)/27 loop: if k> 10 then goto out k=k+1 i=3"k-1 goto loop I out: B) Rewrite the following code segment in C++ using the multiple-selection (switch and if-else) statements. Assume that all the variables are declared and initialized. if((k 1) || (k 2))j-2 k-1 if ((k 3) || ( ks))j - 3.k+1 if (k 4)j-4k-1...
C++ Visual Studio 1. How many iterations are in the following "while" loop? int i = 0; while(i < 20) { ++i; } 2. How many iterations are in the following "for" loop? for(int i = 5; i < 17; i = i + 2) { // Work } How many times will '+' be printed? int i = 0; while(true) { if(i == 5) { break; } cout << "+"; ++i; } 3. How many times will '+' be...
CODE MUST BE IN C 1. Given an int variable n that has been initialized to a positive value and, in addition, int variables k and total that have alreadybeen declared, use a while loop to compute the sum of the cubes of the first n whole numbers, and store this value in total. Thus if n equals 4, your code should put 1*1*1 + 2*2*2 + 3*3*3 + 4*4*4 into total. Use no variables other than n, k, and...
A for loop is given below. Use a while loop to perform the same task. for( i=0;i<=7;i+=2) { Sum=Sum + i; } b: What is value of variable Sum after the end of loop?
Convert the following while loop into a for loop. int 1 - 50: int sum-07 while (sum < 1000) sum - sum + 1; Question 35 (2 points) Saved Given an int variable k that has already been declared, use a while loop to print a single line consisting of 80 dollar signs. Use no variables other than k. int sum = 0; for(int i = 100;sum < 10000;1-- sum = sum + i;
Please answer both questions thank you.
Rewrite the following for loop into a while loop: int s S = 0; for (int i = 1; i <= 10; i++) { S += i; int s = 0; int i = while (i <= 10) S = + i; i++; } int s = 0; int i = 1; while (i <= 10) { s = s + i; i++; } int S = 0; int i = 1; while (i...
In Javascript: While loop: use a while loop to calculate and display the Kelvin temperature values for each Fahrenheit temperature value range from 0 to 100 in increment of 10. use the formula tk = (tf -32) x 5/9 + 273.15 The values should be displayed exactly as shown: -17, -12, -6, -1, 4, 10, 15, 21, 26, 32, 37