Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Loops chapter 4 WS Nested Loops Show the ouput produced by the following segments of code. Assume that all variables are declared as int. 1.

Loops chapter 4 WS Nested Loops

Show the ouput produced by the following segments of code. Assume that all variables are declared as int.

1. for (int k = 0; k < 2; k++)

for (int m= 0; m < 3; m++)

system.out.println (k + " " + m);

2. for (int d =6; d > = 4; d --)

for (int e = 2; e <= 4; e++)

system.out.println)d + " " + e);

3. x = 0;

while (x < 5 )

{

sum = 0;

y = 1;

while ( y <= x)

{

sum += y ; y++;

}

system.out.print( sum + " "); x++;

}

4. for (i = 0 ; i < 5; i++)

{

system.out.println ( i );

for ( j = i; j >= 1; j -= 2)

system.out.println (j);

}

5. for ( i = 0; i < 3; i++)

for ( j = 1 ; j <= 3; j++)

{

for (k = i ; k<= j; k++)

system.out.println ( i + j + k) ;

system.out.println ( );

}

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

Graph Databases In Action

Authors: Dave Bechberger, Josh Perryman

1st Edition

1617296376, 978-1617296376

More Books

Students also viewed these Databases questions

Question

3. You can gain power by making others feel important.

Answered: 1 week ago