Write a Java program to display the pattern.
B
BR
BRA
BRAI
BRAIN
BRAINLY
Restrictions:
• Not to use more than 1 loop.
• Not to use more than 1 variable.
Answers
Answered by
5
public class BrainlyPattern {
public static void main(String[ ] args) {
for (int i = 0; i < "BRAINLY".length( ); )
System.out.println("BRAINLY".substring(0, ++i));
}
}
Answered by
3
QUESTION:-
- Wap in JAVA to print the following pattern
B
BR
BRA
BRAI
BRAIN
BRAINL
BRAINLY
Restrictions:-
- Not to use more than one loop
- Not to use more than one variables
Code:-
package coder;
import java.util.*;
public class PattBrainly
{
public static void main(String ar[])
{
for(int I=1;I<="BRAINLY".length();I++)
{
System.out.println("BRAINLY".substring(0, I) ;
}
}
}
Variable Description:-
- i-- Loop variable
•Output attached
Attachments:
Similar questions
Sociology,
2 months ago
Social Sciences,
2 months ago
Biology,
4 months ago
Chemistry,
10 months ago