Question #145522

Produce the equivalent ‘for’ loop for the while loop presented below. Make use of pseudocode to formulate your answer.

start
Declarations
num count = 0
while count < 5
output “Hello World”
set count = count + 1
endwhile stop

Expert's answer

public class HelloWorld{

     public static void main(String []args){
         int count=0,i;
         System.out.println("---------------While Loop---------------------");
         while(count<5){
        System.out.println("Hello World");
        count=count+1;
         }
         
         System.out.println("---------------For loop---------------------");
         for(i=0;i<5;i++){
             System.out.println("Hello World");
         }
     }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS