What are the three required expressions of a for-loop


Part 1: Writing Exercise:

The following are the exercises about the loops in Java. Write the answers in a comment block before the code of Part2.

a. What are the three required expressions of a for-loop?

b. Consider the following code. This code was written to generate the output as shown in

Output 2. However, there is an error in this code. Correct the code so that it is able to generate the desired output. (2 pts)

int count = 0;
while (count < 10)
{
System.out.println("count:" + count);
}
Output 2
count:0
count:1
count:2
count:3
count:4
count:5
count:6
count:7
count:8
count:9

c. What is the output of the following code?

int i =0;
do
{
System.out.println("i is : " + i);
i++;
}while(i < 5);

Solution Preview :

Prepared by a verified Expert
JAVA Programming: What are the three required expressions of a for-loop
Reference No:- TGS01129775

Now Priced at $20 (50% Discount)

Recommended (93%)

Rated (4.5/5)