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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started