Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!