Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. What values of i will the following loops iterate over? Give an explicit sequence for each for loop. If a loop is innite, just

1. What values of i will the following loops iterate over? Give an explicit sequence for each for loop. If a loop is innite, just give the rst few elements of the sequence and then use ... to mean that it continues on to innite (technically, Java integers would overow and wrap around to negative values, but ignore that for this question). (a) for (int i=2; i<=7; i++)

(b) for (int i=7; i>2; i--)

(c) for (int i=2; i<9; i+=3) (d) (1 point) for (int i=7; i>2; i+=2) (e) (1 point) for (int i=1; i<=20; i*=2) (f) (1 point) for (int i=7; i<=2; i--) 2. What is the output of the following code fragment? int prod = 1; for(int i=7; i > 4; i = i - 2) { prod = prod * i; } System.out.println(prod); 3. What does the following nested loop print out? for (int r=1; r <=5; ++r) { double x =10.0*r; for (int c=1; c<=5; ++c) { System.out.printf("%5.2f",c/x); } System.out.println(); } 4. What are the values in arrays a and b after the following code executes (list all of the elements of both arrays)? double[] a = new double[4]; double[] b = {6,4,2,0}; a[1] = b[0] + b[2]; a[a.length-1] = b[1]; b[0] = b[0]+a[1];

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

PostgreSQL 10 High Performance Expert Techniques For Query Optimization High Availability And Efficient Database Maintenance

Authors: Ibrar Ahmed ,Gregory Smith ,Enrico Pirozzi

3rd Edition

1788474481, 978-1788474481

More Books

Students also viewed these Databases questions

Question

What is the basic formula for the markup percentage?

Answered: 1 week ago

Question

What are the six bottleneck principles discussed in the text? LO.1

Answered: 1 week ago

Question

=+Is the guilt appropriate for the organization?

Answered: 1 week ago

Question

Regorafenib Drug for advanced Gastrointestinal Stromal Tumors

Answered: 1 week ago

Question

9. Describe the characteristics of power.

Answered: 1 week ago

Question

10. Describe the relationship between communication and power.

Answered: 1 week ago