Question

check) Determine the value in total after each of the following loops is executed for (i=i; i <-10; i-i+1) 3. (Desk a. total o total- total + 1i b. total 1; for (count 1; count <- 10, count count + 1) total = total * 2; c. total-0 for (i10; i 15: i i+ 1) total total ii d. total = 50; for (i -1: i <10; i i + 1) total = total - i; e. totall; for (icnt 1; icnt <8 +ticnt) total total * icnt; f. total1.0 for (j 1; j < 5; ++j) total total / 2.0
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Question a:

Answer: 10

Question b:

Answer: 1024

Question c:

Answer:  75

Question d:

Answer: -5

Question e:

Answer: 40320

Question f:

Answer: 0.03125

Add a comment
Know the answer?
Add Answer to:
check) Determine the value in total after each of the following loops is executed for (i=i;...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • [Textbook Chapter 5 Self-Check Problems: Question 2] Convert each of the following for loops into an...

    [Textbook Chapter 5 Self-Check Problems: Question 2] Convert each of the following for loops into an equivalent while loop: for (int n = 1; n <= max; n++){ System.out.println(n): int total = 25: for (int number - 1; number <= (total/2): number++){ total total number: System.out.println(total +""+ number): for (int i = 1; i <= 2; i++) { for (int j = 1; j <= 3; j++){ for (int k = 1; k<= 4; k++) { System.out.print("*"); System.out.print("!"); System.out.println(); int...

  • Poly-Poly + a[i] * power 6. (15%) Consider the nested loops shown below, where N is...

    Poly-Poly + a[i] * power 6. (15%) Consider the nested loops shown below, where N is assumed to be a power of 2. i.e., N-2 for some positive integer k. i=N; while (i>-1){ while (j =N){ j-2 *j; i=i/2. a) Determine the number of outer iterations (associated with the outer while loop) to be executed? Show your work. b) For each outer iteration (for each value of i), determine the number of iterations of the inner while loop to be...

  • After the following declarations and statements are executed:       int i, j, k ;       boolean...

    After the following declarations and statements are executed:       int i, j, k ;       boolean c;       float x, y,   z;       int[ ] num = {4, 1, 2, 3, 8};       i = 3;       j = 5;       x = 4.3;       y = 58.209;       c = !(i > j) ; what is the value of c

  • Write Matlab Determine the constant of array A after the following statement are executed A=[4 7...

    Write Matlab Determine the constant of array A after the following statement are executed A=[4 7 3; 9 12 6; 7 6 9] i. A([1,3],:)=A([2],:) ii. C=eye(3,3) b=[1 2 3] C(2,:)=b

  • 6. First try to predict how many times will the following for loops execute? What is...

    6. First try to predict how many times will the following for loops execute? What is the output for (i = 17; i>1; i = i/2) for (i = 2; j <i; j = 1 + 3) cout <<j«<i+j << endl; Then create a main program to include this code, compile and run to check your prediction -7. Write a program to show the first two passes in the execution of the Bubble sort on the following ordered set (show...

  • 1. Which of the following is declared correctly and will not result in an error, assuming...

    1. Which of the following is declared correctly and will not result in an error, assuming x 2 and y307 a) for (var j - 10; j < 80, - ) b) for (var 1 - x, c) for (var 1- d) for (var j = x 1 y ) + 5) -80 y: 1 - 5 /*) <= 80 • y: 1 -- 5) 2. The multiple-selection statement is used to handle decision making and can be used to...

  • What will be the value of x after the following code is executed? int x =...

    What will be the value of x after the following code is executed? int x = 5; while (x <50) { x += 5; } a) 50 b) 45 c) Infiniteloop d) 55 Given the following code segment: Scanner in = new Scanner (System.in); boolean done = false; while (!done) { int input = in.next(); if(input.equalsIgnoreCase("q")) done = false; } What will cause the loop to terminate? a) When the user enters -1 b) The loop will never terminate c)...

  • Find the worst case runtime f(n) for the following algorithms. Specify the number of operations executed...

    Find the worst case runtime f(n) for the following algorithms. Specify the number of operations executed for an input size n, for the worst case run time as a function of n. Circle statement(s) and draw a   line to the right side specifying the number of operations. If statement(s) are a part of an iteration of n, specify the total number of iterations as a function of n. Algorithm-01 int sum = 0; int j = 1; while ( <=...

  • 2. What is the value of x alter the following code is executed # include<iostream> using...

    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...

  • i.) If the commands below will be executed in order, determine the output of the 4...

    i.) If the commands below will be executed in order, determine the output of the 4 echo commands (labeled as A-D): ( 2 Marks ) export z=3 e=10 echo $e - A bash echo $z -B k=4 sh Z=7 echo $k -C exit exit echo $z -D ii.) Given the contents of file (filename: /home/user5/research) below, write the single command line needed to perform the following tasks. SUMMARY GLOSSARY CHAPTER 1 Introduction and Research Approach Reach Obiective REFERENCES APPENDIX A...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT