- Home
- Output Questions for Class 10 ICSE Computer Applications
Give the output of the following Java program snippet based
Output Questions for Class 10 ICSE Computer Applications
Give the output of the following Java program snippet based on nested loops:
int a,b;
for (a=1; a<=2; a++)
{
for (b= (64+a); b<=70; b++)
System.out.print((char) b);
System.out.println( );
}
Answer
ABCDEF BCDEF
Working
In the first iteration of outer for loop, the inner for loop will print characters with ASCII codes from 65 to 70 i.e. letters from A to F.
In the second iteration of outer for loop, the inner for loop will print characters with ASCII codes from 66 to 70 i.e. letters from B to F.