Write a nested loop to display the following pattern: (Do not write a program)
A B C D
A B C D
A B C D
A B C D
Answers
Answered by
0
Answer:
Only nested loop:-
int a,b;
for(a=1;a<=4;a++)
{
for(b=65;b<=68;b++)
{
System.out.print((char)b + " ");
}
System.out.println();
}
Description:-
- Variable a and b are initialised
- Condition is checked 1<=4 it is true so body enters the inner loop.
- Inner loop is executed until it is true.First it prints A then B then C then D.
- It will print until the condition is true i.e when 4<=4 now the loop is terminated.
- See the program and output in the attachment.
Attachments:
Similar questions