Write a program in java to print the following pattern :-
B
LL
UUU
EEEE
Answers
Answered by
6
Language:
JAVA
Program:
import java.util.*;
public class oh
{public static void main(String[] args)
{String a = "BLUE";
for (int i = 0; i < a.length(); i++)
{for (int j = 0; j <= i; j++)
{System.out.print(a.charAt(i));}
System.out.println();}}}
Output:
Consider the attachments.
Explanation:
- Save "BLUE" in a string variable.
- Print index+1 times the letter in the same line with a loop.
- Adds new line with a loop.
Attachments:
Attachments:
Answered by
10
Attachments:
Similar questions