Computer Science, asked by thanujvenugopal, 1 year ago

write a program to print the following pattern (IN java)

Attachments:

Answers

Answered by AniketSoftDev
3
String name = "BLUE";

for(int i = 0 ; i<name.length();i++){

char c = name.charAt(i);
for(int y = 0;y <i+1;y++)
{
System.out.print(c);
}
System.out.print("/n");
}

QGP: By the way, just a correction. The escape sequence for new line is "\n"
Answered by QGP
4
public class Pattern
{
    public static void main(String[] args)
    {
        String str = "BLUE";
        
        for(int i=0;i<4;i++)
        {
            char ch = str.charAt(i);
            for(int j=0;j<=i;j++)
            {
                System.out.print(ch);
            }
            System.out.println();
           
        }
    }
}



QGP: I actually edited a previous program
AniketSoftDev: plz remove that ch++
QGP: Done
QGP: Thanks for pointing that out :)
AniketSoftDev: by the way I am 14 years old
AniketSoftDev: and my software is out
QGP: Nice! Wow!!!!
AniketSoftDev: plz check it here
AniketSoftDev: www.umpmax.tk
AniketSoftDev: requires java 9.0.0
Similar questions