Computer Science, asked by anindyaadhikari13, 4 months ago

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 Oreki
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 BrainlyProgrammer
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