aaaa bbbb AAAA BBBB pattern program in java
Answers
Answered by
2
The java program for the following pattern is as follows:
class Pattern
{
public static void main(String args[]) {
int x = 97;
for (int a = 1; a<= 4; a++) {
for (int b = 1; b <= 4; b++) {
System.out.print((char)x + " ");
}
x++;
if (a == 2)
x = 65;
System.out.println();
}
}
}
Output:
aaaa
bbbb
AAAA
BBBB
Explanation:
Refer to the attachment:
Line 4: Initializing x = 97 to convert it into lower case character.
Line 5: Loop 1 for columns
Line 6: Loop 2 for rows
Line 7 : Converting into char and printing.
Line 10, 11: Chainging lowercase to uppercase as x = 65 will be A as per ASCII rules.
Attachments:
Answered by
1
Answer:
GJTNJ
Explanation:
Similar questions
English,
6 months ago
Social Sciences,
6 months ago
India Languages,
6 months ago
India Languages,
11 months ago
Math,
11 months ago
Chemistry,
1 year ago
Chemistry,
1 year ago