Computer Science, asked by purwasingh2222, 11 months ago

Find the error
for(count = 0, count < 5, count = count + 1)
System.out.println("This is count:" + count);
System.out.println("Done!");​

Answers

Answered by prathyusha531
1

Answer:

This is count:0

This is count:1

This is count:2

This is count:3

This is count:4

Done!

Explanation:

  • count starts with 0 and for every increment it prints the value
  • The loops repeats until the condition fails " count<5 "
  • After all the values it prints "Done ! "
  • Done only prints for a single time
  • Because the loops doesn't have braces , so it executes only single statement after loop statement
Answered by ridhimakh1219
8

Compilation error due to semicolon ;

Explanation:

Compilation failed due to following error(s).

error: ';' expected

error: illegal start of expression

There should be semicolon instead of comma in statement for(count = 0; count < 5; count = count + 1)

Correct program in Java

public class Main

{

public static void main(String[] args) {

    int count;

      for(count = 0; count < 5; count = count + 1)

              System.out.println("This is count:" + count);

              System.out.println("Done!");

}

}

Output

This is count:0                            

This is count:1      

This is count:2              

This is count:3                        

This is count:4                  

Done!                                                                                                                

Similar questions