ICSE Class 10 Computer Applications
Question 28 of 30
Solved Sample Paper 4 — Question 28
Back to all questions 28
Question Question 2(viii)
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);The corrected code is as follows:
int x = 4, y = 8;
do
{
y = y + (x++);
} while (x <= 10);
System.out.println(y);| Statement | Error |
|---|---|
| Int x = 4, y = 8; | int is a keyword and should be written in lowercase |
| The user needs to use do while loop | The 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) |