KnowledgeBoat Logo

Computer Applications

The following code has some error(s). Identify the errors and write the corrected code.

Int x = 4, y = 8;
{
    y = y + (x++)
} while (x <= 10) 
System.out.println(y);

Java Iterative Stmts

4 Likes

Answer

The corrected code is as follows:

int x = 4, y = 8;
do
{
    y = y + (x++);
} while (x <= 10);
System.out.println(y);
StatementError
Int x = 4, y = 8;int is a keyword and should be written in lowercase
The user needs to use do while loopThe do-while loop structure is used incorrectly, as the do keyword is missing.
y = y + (x++)Semicolon should be written at the end of the statement
while (x <= 10)A semicolon should be written after the while(x <= 10)

Answered By

3 Likes


Related Questions