Computer Science, asked by BrainlyProgrammer, 3 months ago

Find the output for the given snippet:

for(I=1;I<=5;I++);
{
for(j=1;j<=5;j++);
{
System.out.println("Congrats!!anindyadikari you won the challenge");
}
}​

Answers

Answered by anindyaadhikari13
2

Question:-

  • Find the output of the given snippet.

Solution:-

Given code,

int I, j;

for(I=1;I<=5;I++);

{

for(j=1;j<=5;j++);

{

System.out.println("Congrats!! Anindya Adhikari you won the challenge");

}

}

This is a very tricky question, many students will make the mistake by not seeing the semicolon at the end of the loop.

Many students will write(by mistake) that the output is,

"Congrats!! Anindya Adhikari you won the challenge" printed 25 times.

But, the actual output is:- Congrats!! Anindya Adhikari you won the challenge.

Output:-

  • Congrats!! Anindya Adhikari you won the challenge
Similar questions