Answer to Question #145522 in Computer Networks for Nhlanhla

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
1
Expert's answer
2020-11-23T06:38:33-0500
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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS